actions.lua (1280B)
1 if not pcall(require, 'actions') then 2 return 3 end 4 5 local utils = require 'actions.utils' 6 7 local actions = {} 8 local mappings = { ['n <space>ar'] = 'run', ['n <space>at'] = 'test', ['n <space>ab'] = 'build' } 9 10 local function make(_) 11 vim.cmd.make() 12 end 13 14 local add = function(action) 15 table.insert(actions, action) 16 end 17 18 local add_lang = function(lang, a) 19 add { predicate = utils.make_language_predicate(lang), actions = a } 20 end 21 22 add_lang('dart', { 23 run = make, 24 build = function(_) -- analyze 25 require('tms.ft.dart.analyze').qf2103() 26 end, 27 }) 28 29 add_lang('lua', { run = make }) 30 31 add_lang('go', { 32 run = function(_) 33 vim.bo.makeprg = 'go run %' 34 vim.cmd.make() 35 vim.cmd.compiler('go') 36 end, 37 test = function(_) 38 vim.bo.makeprg = 'go test' 39 vim.cmd.make() 40 vim.cmd.compiler('go') 41 end, 42 build = make, 43 }) 44 45 add_lang('zsh', { 46 run = function(_) 47 vim.bo.makeprg = [[./%]] 48 vim.bo.efm = [[%f:%.%#:%l:\ %m,%f:%l:\ %m,%-G%.%#]] 49 vim.cmd.make() 50 vim.cmd.compiler('zsh') 51 end, 52 build = make, 53 }) 54 55 add_lang('gdscript', { 56 run = function(_) 57 vim.api.nvim_command('GodotRun') 58 end, 59 build = function(_) 60 vim.api.nvim_input(':GodotRun ') 61 end, 62 }) 63 64 add_lang('sh', { run = make }) 65 66 actions.mappings = mappings 67 require('actions'):setup(actions)