fix gotests template parameters, better names(?), small formatting fixes, update README (#125)

pull/117/head
Marco Mayer 2 years ago committed by GitHub
parent 1c727c8768
commit eba7daeb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@ The plugin covers most features required for a gopher.
- Test with ginkgo, richgo inside floaterm (to enable floaterm, guihua.lua has to be installed)
- Go 1.18 support, configure your go to `go1.18` in config
- GoFixPlural, FixStruct, FxiSwitch, Add comment, IfErr, ModTidy, GoGet ... Most of the tools are built on top of
treesitter AST or go AST. It is fast and accurate.
treesitter AST or go AST. It is fast and accurate.
## Installation
@ -85,9 +85,11 @@ require('go').setup()
![gotest](https://user-images.githubusercontent.com/1681295/143160335-b8046ffa-82cd-4d84-af3e-3b0dbb4c609e.png)
Use:
```vim
:GoTermClose
```
To close the floating term.
## refactor gorename
@ -198,7 +200,7 @@ first run of `GoFmt` may fail. It is recommended to run `GoInstallBinaries` to i
| GoBuild | |
| GoGenerate | |
| GoRun | e.g. GoRun equal to `go run .`; or `GoRun ./cmd` equal to `go run ./cmd` |
| GoStop {job_id} | `stop the job started with GoRun` |
| GoStop {job_id} | `stop the job started with GoRun` |
| GoTest | go test ./... |
| GoTest -c | go test -c current_file_path |
| GoTest -tags=yourtags | go test ./... -tags=yourtags |
@ -263,11 +265,11 @@ Modify struct tags by [`gomodifytags`](https://github.com/fatih/gomodifytags) an
nvim-lsp support goimport by default. The plugin provided a new formatter, goline + gofumpt (stricter version of
gofmt)
| command | Description |
| -------- | --------------------------- |
| GoFmt | goline + gofumpt |
| GoImport | goline + goimport + gofumpt |
| GoImport package_path | gopls add_import package |
| command | Description |
| --------------------- | --------------------------- |
| GoFmt | goline + gofumpt |
| GoImport | goline + goimport + gofumpt |
| GoImport package_path | gopls add_import package |
## GoImpl
@ -295,15 +297,15 @@ e.g:
| command | Description |
| ---------------- | ------------------------------------------------ |
| GoDebug | start debug session |
| GoDebug -t | start debug session for go test file |
| GoDebug -R | restart debug session for go test file |
| GoDebug -n | start debug session for nearest go test function |
| GoDebug -f | same as GoDebug |
| GoDebug -p | debug package |
| GoDebug -a | attach to remote process |
| GoDebug -s | stop debug session and unmap debug keymap |
| GoBreakToggle | GoDebug -b |
| GoBreakCondition | conditional break |
| GoDebug -t | start debug session for go test file |
| GoDebug -R | restart debug session for go test file |
| GoDebug -n | start debug session for nearest go test function |
| GoDebug -f | same as GoDebug |
| GoDebug -p | debug package |
| GoDebug -a | attach to remote process |
| GoDebug -s | stop debug session and unmap debug keymap |
| GoBreakToggle | GoDebug -b |
| GoBreakCondition | conditional break |
## Switch between go and test file
@ -335,11 +337,12 @@ type GoLintComplaining struct{}
```
## GoModeTidy
run `go mod tidy` and restart gopls
## GoModeVendor
run `go mod vendor` and restart gopls
run `go mod vendor` and restart gopls
## LSP
@ -349,6 +352,7 @@ The goal of go.nvim is more provide unique functions releated to gopls instead o
The lsp config in go.nvim has a none default setup and contains some improvement and I would suggest you to use.
## LSP cmp support
The latest version enabled lsp snippets (and other setups) by default. In case you need flowing the setup from cmp
README.md, please use flowing command:
@ -469,8 +473,8 @@ require('go').setup({
gofmt = 'gofumpt', --gofmt cmd,
max_line_len = 120, -- max line length in goline format
tag_transform = false, -- can be transform option("snakecase", "camelcase", etc) check gomodifytags for details and more options
test_template = '', -- g:go_nvim_tests_template check gotests for details
test_template_dir = '', -- default to nil if not set; g:go_nvim_tests_template_dir check gotests for details
gotests_template = "", -- sets gotests -template parameter (check gotests for details)
gotests_template_dir = "", -- sets gotests -template_dir parameter (check gotests for details)
comment_placeholder = '' , -- comment_placeholder your cool placeholder e.g. ﳑ    
icons = {breakpoint = '🧘', currentpos = '🏃'}, -- setup to `false` to disable icons setup
verbose = false, -- output loginf in messages

@ -10,7 +10,10 @@ _GO_NVIM_CFG = {
gofmt = "gofumpt", -- if set to gopls will use gopls format
max_line_len = 120,
tag_transform = false,
test_dir = "",
gotests_template = "", -- sets gotests -template parameter (check gotests for details)
gotests_template_dir = "", -- sets gotests -template_dir parameter (check gotests for details)
comment_placeholder = "",
icons = { breakpoint = "🧘", currentpos = "🏃" }, -- set to false to disable icons setup
verbose = false,
@ -132,7 +135,9 @@ function go.setup(cfg)
-- e.g. GoTestFile unit
vim.cmd([[command! -nargs=* GoTestFile lua require('go.gotest').test_file(<f-args>)]])
vim.cmd([[command! -nargs=* -complete=custom,v:lua.package.loaded.go.package_complete GoTestPkg lua require('go.gotest').test_package(<f-args>)]])
vim.cmd(
[[command! -nargs=* -complete=custom,v:lua.package.loaded.go.package_complete GoTestPkg lua require('go.gotest').test_package(<f-args>)]]
)
vim.cmd([[command! -nargs=* GoAddTest lua require("go.gotests").fun_test(<f-args>)]])
vim.cmd([[command! -nargs=* GoAddExpTest lua require("go.gotests").exported_test(<f-args>)]])
vim.cmd([[command! -nargs=* GoAddAllTest lua require("go.gotests").all_test(<f-args>)]])

@ -2,13 +2,13 @@
-- https://github.com/cweill/gotests
local ut = {}
local gotests = "gotests"
local test_dir = _GO_NVIM_CFG.test_dir or ""
local test_template = vim.go_nvim_test_template or ""
local gotests_template = _GO_NVIM_CFG.gotests_template or ""
local gotests_template_dir = _GO_NVIM_CFG.gotests_template_dir or ""
local utils = require("go.utils")
local empty = utils.empty
local run = function(setup)
print(vim.inspect(setup))
vim.fn.jobstart(setup, {
vim.fn.jobstart(setup, {
stdout_buffered = true,
on_stdout = function(_, data, _)
print("unit tests generate " .. vim.inspect(data))
@ -29,12 +29,12 @@ local new_gotests_args = function(parallel)
if parallel then
table.insert(args, "-parallel")
end
if string.len(test_template) > 0 then
if string.len(gotests_template) > 0 then
table.insert(args, "-template")
table.insert(args, test_template)
if string.len(test_dir) > 0 then
table.insert(args, gotests_template)
if string.len(gotests_template_dir) > 0 then
table.insert(args, "-template_dir")
table.insert(args, test_dir)
table.insert(args, gotests_template_dir)
end
end
return args

Loading…
Cancel
Save