* feat(utils): first impl of own commands runner * refactor(gotests): uses own runner instead of vendored * refactor(utils): back to plenary.job * refactor(gotests): use new runner, clean code * fix(runner): now it returns output correctly * refactor(iferr): use vim.system i have tried to use _utils.runner, but i can't figure out how to make `< file.go` for the command * refactor(impl): use new runner * refactor(installer): use new runner * refactor(struct_tags): use new runner * refactor: commands such as :GoGet runs with new runner * refactor: throw errors in more lua way, i think * refactor(utils): notify now has title * refactor: use more correct way of notifying * refactor(runner): write error message on error |
||
|---|---|---|
| .github/workflows | ||
| autoload/health | ||
| lua/gopher | ||
| plugin | ||
| spec | ||
| .editorconfig | ||
| .gitignore | ||
| .luarc.json | ||
| CONTRIBUTING.md | ||
| nvim.toml | ||
| README.md | ||
| selene.toml | ||
| stylua.toml | ||
| Taskfile.yml | ||
gopher.nvim
Minimalistic plugin for Go development in Neovim written in Lua.
It's not an LSP tool, the main goal of this plugin is add go tooling support in Neovim.
Install
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 go parser if isn't installed yet.
Config
By .setup function you can configure the plugin.
Note:
installerdoes not install the tool in user set path
require("gopher").setup {
commands = {
go = "go",
gomodifytags = "gomodifytags",
gotests = "~/go/bin/gotests", -- also you can set custom command path
impl = "impl",
iferr = "iferr",
},
}
Features
- Installation requires this go tool:
:GoInstallDeps
It will install next tools:
- Modify struct tags:
By default
jsontag will be added/removed, if not set:
:GoTagAdd json " For add json tag
:GoTagRm yaml " For remove yaml tag
- Run
go modcommand:
:GoMod tidy " Runs `go mod tidy`
:GoMod init asdf " Runs `go mod init asdf`
- Run
go getcommand
Link can have a http or https prefix.
You can provide more than 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 generatecommand;
" Run `go generate` in cwd path
:GoGenerate
" Run `go generate` for current file
:GoGenerate %
- Generate doc comment
First set a cursor on public package/function/interface/struct and execute:
:GoCmt
- Generate
if err
Set cursor on the line with err and execute:
:GoIfErr
- Setup nvim-dap for go in one line.
Notice: nvim-dap is required
require"gopher.dap".setup()
Contributing
PRs are always welcome. See CONTRIBUTING.md