go.nvim/lua/go.lua

48 lines
2.5 KiB
Lua
Raw Normal View History

2021-03-10 12:15:06 +00:00
-- some of commands extracted from gopher.vim
local go = {}
function go.setup(cfg)
2021-03-10 20:07:31 +00:00
cfg=cfg or {}
2021-03-10 12:15:06 +00:00
vim.g.go_nvim_goimport = cfg.goimport or 'gofumports' -- g:go_nvim_goimport
vim.g.go_nvim_gofmt = cfg.gofmt or 'gofumpt' --g:go_nvim_gofmt,
2021-04-14 04:45:48 +00:00
vim.g.go_nvim_max_len = cfg.max_len or 120 -- g:go_nvim_max_len
2021-03-10 12:15:06 +00:00
vim.g.go_nvim_transform = cfg.transform or false -- vim.g.go_nvim_tag_transfer check gomodifytags for details
vim.g.go_nvim_test_dir = cfg.test_dir or '' -- default to current dir. g:go_nvim_tests_dir check gotests for details
vim.g.go_nvim_comment_placeholder = cfg.comment_placeholder or '' -- vim.g.go_nvim_comment_placeholder your cool placeholder e.g. ﳑ    
vim.g.go_nvim_verbose = cfg.verbose or false -- output loginf in messages
2021-03-10 21:35:30 +00:00
vim.cmd("command! Gmake silent lua require'go.asyncmake'.make()")
2021-03-10 12:15:06 +00:00
vim.cmd('command Gofmt lua require("go.format").gofmt()')
vim.cmd('command Goimport lua require("go.format").goimport()')
2021-03-10 20:07:31 +00:00
2021-03-10 21:35:30 +00:00
vim.cmd([[command GoBuild :setl makeprg=go\ build | :Gmake]])
vim.cmd([[command GoGenerate :setl makeprg=go\ generate | :Gmake]])
vim.cmd([[command GoRun :setl makeprg=go\ run | :Gmake]])
vim.cmd([[command GoTestFunc :Gmake -run ..]])
2021-03-10 12:15:06 +00:00
2021-03-10 22:21:24 +00:00
vim.cmd([[command GoTest :setl makeprg=go\ test\ ./... | :Gmake]])
2021-03-10 21:35:30 +00:00
vim.cmd([[command GoTestCompile setl makeprg=go\ build | :Gmake]])
2021-03-10 12:15:06 +00:00
vim.cmd([[command GoAddTest lua require("go.gotests").fun_test()]])
vim.cmd([[command GoAddExpTest lua require("go.gotests").exported_test()]])
vim.cmd([[command GoAddAllTest lua require("go.gotests").all_test()]])
vim.cmd([[command! -nargs=* GoAddTag lua require("go.tags").add(<f-args>)]])
vim.cmd([[command! -nargs=* GoRmTag lua require("go.tags").rm(<f-args>)]])
vim.cmd([[command GoClearTag lua require("go.tags").clear()]])
2021-03-12 02:54:08 +00:00
vim.cmd([[command GoCmt lua require("go.comment").gen()]])
2021-04-21 11:11:44 +00:00
vim.cmd([[command GoRename lua require("go.rename").run()]])
2021-04-23 06:31:00 +00:00
vim.cmd([[command Giferr lua require("go.iferr").run()]])
vim.cmd([[command Gfstruct lua require("go.reftool").fillstruct()]])
vim.cmd([[command Gfswitch lua require("go.reftool").fillstruct()]])
2021-03-10 12:15:06 +00:00
2021-03-10 22:21:24 +00:00
-- vim.cmd([[command GoLint :compiler golangci-lint run | :Gmake]])
vim.cmd([[command GoLint :setl makeprg=golangci-lint\ run\ --out-format\ tab | :Gmake]])
2021-03-10 21:35:30 +00:00
vim.cmd("au FileType go au QuickFixCmdPost [^l]* nested cwindow")
vim.cmd("au FileType go au QuickFixCmdPost l* nested lwindow")
2021-03-10 12:15:06 +00:00
end
return go