Minimalistic plugin for Go development in Neovim written in Lua.
It's not an LSP tool, the main goal of this plugin add go tooling support in neovim.
Pre-dependency: go (tested on 1.17 and 1.18)
use {
"olexsmir/gopher.nvim",
requires = { -- dependencies
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
}
Also, run TSInstall go
if install the go
parser if not installed yet.
- Install requires go tools:
:GoInstallDeps
This will install next tools:
- Modify struct tags:
By default be added/removed
json
tag, if not set.
:GoTagAdd json " For add json tag
:GoTagRm yaml " For remove yaml tag
- Run
go mod
command
:GoMod tidy " Runs `go mod tidy`
:GoMod init asdf " Runs `go mod init asdf`
- Run
go get
command
Link can has a http
or https
prefix.
You can provide more that one package url.
:GoGet github.com/gorilla/mux
- Interface implementation
Command syntax:
:GoImpl [receiver] [interface]
" Also you can put cursor on the struct and run:
:GoImpl [interface]
Example of usage:
" Example
:GoImpl r Read io.Reader
" or simply put your cursor in the struct and run:
:GoImpl io.Reader
- Generate tests with gotests
Generate one test for spesific function/method
:GoTestAdd
Generate all tests for all functions/methods in current file
:GoTestsAll
Generate tests only for exported functions/methods in current file
:GoTestsExp
- Run
go generate
command
" Run `go generate` in cwd path
:GoGenerate
" Run `go generate` for current file
:GoGenerate %