From b11ee41a4856caebf67643daceb3062092224798 Mon Sep 17 00:00:00 2001 From: Joshua Finch Date: Wed, 6 Mar 2024 12:34:15 -0600 Subject: [PATCH] Rewrite of the custom functions to better load with the newer modular configs. --- nvim/lua/custom_functions.lua | 53 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/nvim/lua/custom_functions.lua b/nvim/lua/custom_functions.lua index baa536b..a924c72 100644 --- a/nvim/lua/custom_functions.lua +++ b/nvim/lua/custom_functions.lua @@ -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 -- 'if mod then' can wrap code dependent upon the require, and fails gracefully -local function softrequire(m) - local ok, err = pcall(require, m) - if not ok then return nil, err end - return err -end +-- local function softrequire(m) + -- local ok, err = pcall(require, m) + -- if not ok then return nil, err end + -- return err +-- end -local function execute(type) - local command_table = { - run = { - java = 'java %', - python = 'python %', - rust = 'cargo run', - }, - test = { - python = 'python test', - rust = 'cargo test', - }, - benchmark = { - rust = 'cargo bench', - }, - } - vim.api.nvim_command('write') - local command = command_table[type][vim.bo.filetype] +return { + execute = function(type) + local command_table = { + run = { + java = 'java %', + python = 'python %', + rust = 'cargo run', + }, + test = { + python = 'python test', + rust = 'cargo test', + }, + benchmark = { + rust = 'cargo bench', + }, + } + vim.api.nvim_command('write') + local command = command_table[type][vim.bo.filetype] - if command ~= nil then - vim.cmd('FloatermNew --autoclose=0 ' .. command) + if command ~= nil then + vim.cmd('FloatermNew --autoclose=0 ' .. command) + end end -end - +}