feat: added command to close floating term (#119)

* feat: added command to close floating term

* feat: automatically close previous float term

* Update go.lua

remove auto complete

Co-authored-by: Ales Brelih <ales.brelih@3fs.si>
Co-authored-by: rayx <rayx.cn@gmail.com>
pull/121/head
Aleš Brelih 2 years ago committed by GitHub
parent 9143b3a4b9
commit ab864c4c17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,6 +81,12 @@ 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
gorename as an alternative to gopls rename as it supports rename across packages
@ -190,16 +196,17 @@ 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 |
| GoTest package_path -tags=yourtags | go test packagepath -tags=yourtags |
| GoTest package_path -tags=yourtags other_args | go test packagepath -tags=yourtags other_args |
| GoLint | golangci-lint |
| GoGet {package_url} | go get package_url and restart gopls. Note1 |
| GoGet {package_url} | go get package_url and restart gopls. Note1 |
| GoVet | go vet |
| GoCoverage | go test -coverprofile |
| GoTermClose | `closes the floating term` |
Note1: if package_url not provided, will check current line is a valid package url or not, if it is valid, will
fetch current url
@ -497,8 +504,8 @@ require('go').setup({
build_tags = "tag1,tag2", -- set default build tags
textobjects = true, -- enable default text jobects through treesittter-text-objects
test_runner = 'go', -- richgo, go test, richgo, dlv, ginkgo
run_in_floaterm = false, -- set to true to run in float window.
--float term recommand if you use richgo/ginkgo with terminal color
run_in_floaterm = false, -- set to true to run in float window. :GoTermClose closes the floatterm
-- float term recommand if you use richgo/ginkgo with terminal color
})
```

@ -270,6 +270,9 @@ COMMANDS *go-nvim-commands*
e.g. GoImpl {receiver} {interface}, will check if cursor is a valid
receiver, if you park cursor on struct name, receiver can be omitted.
e.g ":GoImpl io.Reader", or "GoImpl f *File io.Reader"
:GoTermClose
Closes the floating term.
==============================================================================
OPTIONS *go-nvim-options*

@ -117,6 +117,7 @@ function go.setup(cfg)
[[command! -nargs=* -complete=custom,v:lua.package.loaded.go.package_complete GoTest lua require('go.gotest').test(<f-args>)]]
)
vim.cmd(
[[command! -nargs=* -complete=custom,v:lua.package.loaded.go.package_complete GoCoverage lua require'go.coverage'.run(<f-args>)]]
)
@ -195,6 +196,12 @@ function go.setup(cfg)
vim.cmd([[command! GoDbgStop lua require'go.dap'.stop()]])
end
if _GO_NVIM_CFG.run_in_floaterm then
vim.cmd(
[[command! -nargs=* GoTermClose lua require("go.term").close()]]
)
end
if _GO_NVIM_CFG.lsp_cfg then
require("go.lsp").setup()
if _GO_NVIM_CFG.lsp_diag_hdlr then

@ -20,6 +20,8 @@ local function close_float_terminal()
end
local term = function(opts)
close_float_terminal()
local columns = api.nvim_get_option("columns")
local lines = api.nvim_get_option("lines")

Loading…
Cancel
Save