Update GoAddTests and allow vim command override

pull/6/head
ray-x 3 years ago
parent 9559a8934f
commit f9e75eda64

@ -1,21 +1,19 @@
-- some of commands extracted from gopher.vim -- some of commands extracted from gopher.vim
local go = {} local go = {}
function go.setup(cfg) function go.setup(cfg)
cfg=cfg or {} cfg = cfg or {}
vim.g.go_nvim_goimport = cfg.goimport or 'gofumports' -- g:go_nvim_goimport 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, vim.g.go_nvim_gofmt = cfg.gofmt or 'gofumpt' -- g:go_nvim_gofmt,
vim.g.go_nvim_max_len = cfg.max_len or 120 -- g:go_nvim_max_len vim.g.go_nvim_max_len = cfg.max_len or 120 -- g:go_nvim_max_len
vim.g.go_nvim_transform = cfg.transform or false -- vim.g.go_nvim_tag_transfer check gomodifytags for details 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_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_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 vim.g.go_nvim_verbose = cfg.verbose or false -- output loginf in messages
vim.cmd("command! Gmake silent lua require'go.asyncmake'.make()") vim.cmd("command! Gmake silent lua require'go.asyncmake'.make()")
vim.cmd('command Gofmt lua require("go.format").gofmt()') vim.cmd('command! Gofmt lua require("go.format").gofmt()')
vim.cmd('command Goimport lua require("go.format").goimport()') vim.cmd('command! Goimport lua require("go.format").goimport()')
vim.cmd([[command GoBuild :setl makeprg=go\ build | :Gmake]]) vim.cmd([[command GoBuild :setl makeprg=go\ build | :Gmake]])
vim.cmd([[command GoGenerate :setl makeprg=go\ generate | :Gmake]]) vim.cmd([[command GoGenerate :setl makeprg=go\ generate | :Gmake]])
@ -25,21 +23,21 @@ function go.setup(cfg)
vim.cmd([[command GoTest :setl makeprg=go\ test\ ./... | :Gmake]]) vim.cmd([[command GoTest :setl makeprg=go\ test\ ./... | :Gmake]])
vim.cmd([[command GoTestCompile setl makeprg=go\ build | :Gmake]]) vim.cmd([[command GoTestCompile setl makeprg=go\ build | :Gmake]])
vim.cmd([[command GoAddTest lua require("go.gotests").fun_test()]]) vim.cmd([[command! GoAddTest lua require("go.gotests").fun_test()]])
vim.cmd([[command GoAddExpTest lua require("go.gotests").exported_test()]]) vim.cmd([[command! GoAddExpTest lua require("go.gotests").exported_test()]])
vim.cmd([[command GoAddAllTest lua require("go.gotests").all_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=* GoAddTag lua require("go.tags").add(<f-args>)]])
vim.cmd([[command! -nargs=* GoRmTag lua require("go.tags").rm(<f-args>)]]) vim.cmd([[command! -nargs=* GoRmTag lua require("go.tags").rm(<f-args>)]])
vim.cmd([[command GoClearTag lua require("go.tags").clear()]]) vim.cmd([[command! GoClearTag lua require("go.tags").clear()]])
vim.cmd([[command GoCmt lua require("go.comment").gen()]]) vim.cmd([[command! GoCmt lua require("go.comment").gen()]])
vim.cmd([[command GoRename lua require("go.rename").run()]]) vim.cmd([[command! GoRename lua require("go.rename").run()]])
vim.cmd([[command Giferr lua require("go.iferr").run()]]) vim.cmd([[command! Giferr lua require("go.iferr").run()]])
vim.cmd([[command Gfstruct lua require("go.reftool").fillstruct()]]) vim.cmd([[command! Gfstruct lua require("go.reftool").fillstruct()]])
vim.cmd([[command Gfswitch lua require("go.reftool").fillstruct()]]) vim.cmd([[command! Gfswitch lua require("go.reftool").fillstruct()]])
-- vim.cmd([[command GoLint :compiler golangci-lint run | :Gmake]]) -- vim.cmd([[command GoLint :compiler golangci-lint run | :Gmake]])
vim.cmd([[command GoLint :setl makeprg=golangci-lint\ run\ --out-format\ tab | :Gmake]]) vim.cmd([[command! GoLint :setl makeprg=golangci-lint\ run\ --out-format\ tab | :Gmake]])
vim.cmd("au FileType go au QuickFixCmdPost [^l]* nested cwindow") vim.cmd("au FileType go au QuickFixCmdPost [^l]* nested cwindow")
vim.cmd("au FileType go au QuickFixCmdPost l* nested lwindow") vim.cmd("au FileType go au QuickFixCmdPost l* nested lwindow")

@ -4,21 +4,18 @@ local ut = {}
local gotests = "gotests" local gotests = "gotests"
local test_dir = vim.g.go_nvim_test_dir or "" local test_dir = vim.g.go_nvim_test_dir or ""
local test_template = vim.go_nvim_test_template or "" local test_template = vim.go_nvim_test_template or ""
local utils = require("go").utils local utils = require("go.utils")
local run = function(setup) local run = function(setup)
print(vim.inspect(setup)) print(vim.inspect(setup))
local j = local j = vim.fn.jobstart(setup, {
vim.fn.jobstart( on_stdout = function(jobid, data, event)
setup, print("unit tests generate " .. vim.inspect(data))
{ end,
on_stdout = function(jobid, data, event) on_stderr = function(_, data, _)
print("unit tests generate " .. vim.inspect(data)) print("generate tests finished with message: " .. vim.inspect(setup) .. "error: "
end, .. vim.inspect(data))
on_stderr = function(_, data, _) end
print("failed to generate tests for " .. vim.inspect(setup) .. "error: " .. vim.inspect(data)) })
end
}
)
end end
local add_test = function(args) local add_test = function(args)

Loading…
Cancel
Save