diff --git a/README.md b/README.md index a0f5d28..b292304 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The plugin covers most features required for a gopher. - Runtime lint/vet/compile: Supported by lsp (once you setup up your lsp client), GoLint with golangci-lint also supported - Build/Make/Test: Go.nvim provides supports for these by an async job wrapper. - Test coverage: run test coverage and show coverage sign and function metrics -- Dlv Debug: with [nvim-dap](https://github.com/mfussenegger/nvim-dap) and [Dap UI](https://github.com/rcarriga/nvim-dap-ui). +- Dlv Debug: with [nvim-dap](https://github.com/mfussenegger/nvim-dap) and [Dap UI](https://github.com/rcarriga/nvim-dap-ui). Zero config for your debug setup. - Load vscode launch configuration - Unit test: generate unit test framework with [gotests](https://github.com/cweill/gotests). Run test with richgo/ginkgo/gotestsum/go test @@ -25,13 +25,12 @@ The plugin covers most features required for a gopher. - Go to alternative go file (between test and source) - Test with ginkgo, richgo inside floaterm (to enable floaterm, guihua.lua has to be installed) - Code refactor made easy: GoFixPlural, FixStruct, FixSwitch, Add comment, IfErr, ModTidy, GoGet, extract function/block with codeactions... Most of the tools are built on top of - treesitter AST or go AST. It is fast and accurate. + treesitter AST or go AST. Fast and accurate. - GoCheat get go cheatsheet from [cheat.sh](https://cheat.sh/). - Smart build tag detection when debug/run tests (e.g. `//go:build integration`) - Generate mocks with mockgen - Inlay hints: gopls (version 0.9.x or greater) inlay hints - luasnip: go.nvim included a feature rich luasnips you definitally need to try. -If you are not familiar with luasnip, please checkout [LuaSnip Tutorial](https://www.youtube.com/watch?v=ub0REXjhpmk) and [TJ's Introduction to LuaSnip](https://www.youtube.com/watch?v=Dn800rlPIho) ## Installation @@ -270,11 +269,11 @@ first run of `GoFmt` may fail. Recommended to run `GoInstallBinaries` to install | GoMake | async make, use with other commands | | GoBuild | | | GoGenerate | | -| GoRun {args} | e.g. GoRun equal to `go run .`; or `GoRun ./cmd` equal to `go run ./cmd, Additional args: -F run in floaterm` | +| GoRun {args} | e.g. GoRun equal to `go run .`; or `GoRun ./cmd` equal to `go run ./cmd, Additional args: -F run in floaterm` | | GoStop {job_id} | `stop the job started with GoRun` | | GoTest | go test ./... | | GoTestSum {pkgname} {gotestsum arguments} | run gotestsum and show result in side panel | -| GoTestSum -w | run gotestsum in watch mode | +| GoTestSum -w | run gotestsum in watch mode | | GoTest -v | go test -v current_file_path | | GoTest -c | go test -c current_file_path | | GoTest -n | test nearest, see GoTestFunc | @@ -282,7 +281,7 @@ first run of `GoFmt` may fail. Recommended to run `GoInstallBinaries` to install | GoTest -n 1 | -count=1 flag | | GoTest -p | test current package, see GoTestPkg | | GoTest -t yourtags | go test ./... -tags=yourtags, see notes | -| GoTest -a your_ags | go test ./... -ags=yourags, see notes | +| GoTest -a your_args | go test ./... -args=yourargs, see notes | | GoTest package_path -t yourtags | go test packagepath -tags=yourtags | | GoTest package_path -t yourtags other_args | go test packagepath -tags=yourtags other_args | | GoLint | golangci-lint | @@ -950,6 +949,7 @@ and [snippets for go](https://github.com/ray-x/go.nvim/blob/master/lua/snips/go. For a video demo, please check this: [go.nvim new features work through](https://www.youtube.com/watch?v=tsLnEfYTgcM) +If you are not familiar with luasnip, please checkout [LuaSnip Tutorial](https://www.youtube.com/watch?v=ub0REXjhpmk) and [TJ's Introduction to LuaSnip](https://www.youtube.com/watch?v=Dn800rlPIho) ## Nvim LSP setup diff --git a/lua/go/commands.lua b/lua/go/commands.lua index 6af2e0f..3c7e1f1 100644 --- a/lua/go/commands.lua +++ b/lua/go/commands.lua @@ -320,7 +320,7 @@ return { }) create_cmd('GoDoc', function(opts) - require('go.godoc').run(unpack(opts.fargs)) + require('go.godoc').run(opts.fargs) end, { complete = function(a, l) return package.loaded.go.doc_complete(a, l) diff --git a/lua/go/godoc.lua b/lua/go/godoc.lua index 8a22ed5..82f867e 100644 --- a/lua/go/godoc.lua +++ b/lua/go/godoc.lua @@ -8,10 +8,7 @@ function m.help_complete(_, _, _) if #help_items < 1 then local doc = vfn.systemlist('go help') if vim.v.shell_error ~= 0 then - vim.notify( - string.format('failed to run go help %d', vim.v.shell_error), - vim.log.levels.ERROR - ) + vim.notify(string.format('failed to run go help %d', vim.v.shell_error), vim.log.levels.ERROR) return end @@ -118,19 +115,14 @@ function m.doc_complete(_, cmdline, _) return '' end -m.run = function(kind, func) - if func == nil then - func = kind - kind = nil - end - log(kind, func) +m.run = function(fargs) + log(fargs) - if vim.fn.empty(func) == 1 then + if vim.fn.empty(fargs) == 1 then return vim.lsp.buf.hover() end - -- vim.validate({ func = { func, "table" } }) - local setup = { 'go', 'doc', kind, unpack(func or {}) } + local setup = { 'go', 'doc', unpack(fargs or {}) } -- return vfn.jobstart(setup, { on_stdout = function(_, data, _) diff --git a/lua/go/package.lua b/lua/go/package.lua index 9b638c7..74c5650 100644 --- a/lua/go/package.lua +++ b/lua/go/package.lua @@ -76,7 +76,7 @@ local show_float = function(result) if not textview then util.log('Failed to load guihua.textview') - vim.fn.setloclist(0, {}, ' ', { + vim.fn.setloclist(0, {}, 'r', { title = 'go package outline', lines = result, }) @@ -206,7 +206,7 @@ local show_panel = function(result, pkg, rerender) }) p:open(true) else - vim.fn.setloclist(0, {}, ' ', { + vim.fn.setloclist(0, {}, 'r', { title = 'go package outline', lines = defs, }) diff --git a/lua/go/runner.lua b/lua/go/runner.lua index 2bbe4fc..64392cf 100644 --- a/lua/go/runner.lua +++ b/lua/go/runner.lua @@ -59,7 +59,7 @@ local run = function(cmd, opts) end log(locopts) vim.schedule(function() - vim.fn.setloclist(0, {}, ' ', locopts) + vim.fn.setloclist(0, {}, 'r', locopts) vim.notify('run lopen to see output', vim.log.levels.INFO) end) end diff --git a/lua/go/utils.lua b/lua/go/utils.lua index a0c93b3..7998147 100644 --- a/lua/go/utils.lua +++ b/lua/go/utils.lua @@ -250,9 +250,9 @@ util.log = function(...) str = string.format('[%s %d] %s', os.date(), ms, str) for i, v in ipairs(arg) do if type(v) == 'table' then - str = str .. ' |' .. tostring(i) .. ': ' .. vim.inspect(v) .. '\n' + str = str .. ' |' .. tostring(i) .. ': ' .. vim.inspect(v or 'nil') .. '\n' else - str = str .. ' |' .. tostring(i) .. ': ' .. tostring(v) + str = str .. ' |' .. tostring(i) .. ': ' .. tostring(v or 'nil') end end if #str > 2 then