diff --git a/README.md b/README.md index 69d1e73..f3166ea 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,7 @@ first run of `GoFmt` may fail. It is recommended to run `GoInstallBinaries` to i | GoStop {job_id} | `stop the job started with GoRun` | | GoTest | go test ./... | | GoTestSum {pkgname} | run gotestsum and show result in side panel | +| GoTestSum -w | run gotestsum in watch mode | | GoTest -c | go test -c current_file_path | | GoTest -n | test nearest, see GoTestFunc | | GoTest -f | test current file, see GoTestFile | diff --git a/lua/go.lua b/lua/go.lua index bdc300b..af95c06 100644 --- a/lua/go.lua +++ b/lua/go.lua @@ -104,7 +104,7 @@ _GO_NVIM_CFG = { dap_port = 38697, -- can be set to a number or `-1` so go.nvim will pickup a random port build_tags = "", --- you can provide extra build tags for tests or debugger textobjects = true, -- treesitter binding for text objects - test_runner = "go", -- one of {`go`, `richgo`, `dlv`, `ginkgo`} + test_runner = "gotestsum", -- one of {`go`, `richgo`, `dlv`, `ginkgo`, `gotestsum`} verbose_tests = true, -- set to add verbose flag to tests run_in_floaterm = false, -- set to true to run in float window. trouble = false, -- true: use trouble to open quickfix diff --git a/lua/go/commands.lua b/lua/go/commands.lua index 7260a8a..3891945 100644 --- a/lua/go/commands.lua +++ b/lua/go/commands.lua @@ -173,6 +173,9 @@ return { end, { complete = package.loaded.go.package_complete, nargs = '*' }) create_cmd('GoTestSum', function(opts) + if opts.fargs[1] == '-w' then + return require('go.gotestsum').watch() + end require('go.gotestsum').run(unpack(opts.fargs)) end, { complete = package.loaded.go.package_complete, nargs = '*' }) diff --git a/lua/go/gotestsum.lua b/lua/go/gotestsum.lua index 9809da3..921a9f1 100644 --- a/lua/go/gotestsum.lua +++ b/lua/go/gotestsum.lua @@ -33,7 +33,7 @@ local show_panel = function() vim.notify('guihua not installed') return end - if test_panel == nil then + if test_panel == nil or not test_panel:is_open() then test_panel = panel:new({ header = '   go test  ', render = function(buf)