return { execute = function(type) -- Mapping of filetypes to commands local command_table = { build = { rust = 'cargo build', }, run = { java = 'java %', python = 'python %', rust = 'cargo run', }, test = { cpp = 'make test', python = 'pytest', rust = 'cargo test', }, benchmark = { rust = 'cargo bench', }, upload = { cpp = 'make upload', } } -- Save the file vim.api.nvim_command('write') local command = command_table[type][vim.bo.filetype] if command ~= nil then -- Run command in a new terminal buffer vim.cmd('terminal ' .. command) end end }