Rewrite of the custom functions to better load with the newer modular configs.

This commit is contained in:
Finch 2024-03-06 12:34:15 -06:00
parent 95a58ffb1f
commit b11ee41a48

View File

@ -1,31 +1,32 @@
-- 'softrequire' provides a wrapper around the builtin require. If the require has failed in a `local mod = softrequire('m') call, a quick check of -- 'softrequire' provides a wrapper around the builtin require. If the require has failed in a `local mod = softrequire('m') call, a quick check of
-- 'if mod then' can wrap code dependent upon the require, and fails gracefully -- 'if mod then' can wrap code dependent upon the require, and fails gracefully
local function softrequire(m) -- local function softrequire(m)
local ok, err = pcall(require, m) -- local ok, err = pcall(require, m)
if not ok then return nil, err end -- if not ok then return nil, err end
return err -- return err
end -- end
local function execute(type) return {
local command_table = { execute = function(type)
run = { local command_table = {
java = 'java %', run = {
python = 'python %', java = 'java %',
rust = 'cargo run', python = 'python %',
}, rust = 'cargo run',
test = { },
python = 'python test', test = {
rust = 'cargo test', python = 'python test',
}, rust = 'cargo test',
benchmark = { },
rust = 'cargo bench', benchmark = {
}, rust = 'cargo bench',
} },
vim.api.nvim_command('write') }
local command = command_table[type][vim.bo.filetype] vim.api.nvim_command('write')
local command = command_table[type][vim.bo.filetype]
if command ~= nil then if command ~= nil then
vim.cmd('FloatermNew --autoclose=0 ' .. command) vim.cmd('FloatermNew --autoclose=0 ' .. command)
end
end end
end }