sync develop with main (#119)
* chore: remove unused rules from nvim selene setup * test: add test for config * chore: update tasks, run tests on all recent versions * refactor(test): make helper test function more ergonomic In my opinion, requiring user to access tests via `T["module_name"]` was too fragile and typos prone. * fix(config): typo annotations * chore(ci): install go bins via gopher.nvim itself * feat(struct_tags): add range support (#117) * feat(struct_tags): add range support * refactor: use `start`, and `end_` naming for ranges * fix(testutils): validate provided cursor position * chore: update CONTRIBUTING.md * chore: add demos (#118) * chore: add dataset for demos * chore(demos): add demos * chore: update CONTRIBUTING * this copefully will fix comments gif * chore: add note about lazy loading * chore(readme): at this point there is no code from go.nvim or iferr * chore(readme): update the structure * chore(readme): change wording of some things
This commit is contained in:
parent
de585144eb
commit
76e817b5e1
37 changed files with 472 additions and 188 deletions
112
README.md
112
README.md
|
|
@ -4,19 +4,21 @@
|
|||
|
||||
Minimalistic plugin for Go development in Neovim written in Lua.
|
||||
|
||||
It's **NOT** an LSP tool, the main goal of this plugin is to add go tooling support in Neovim.
|
||||
It's **NOT** an LSP tool, the goal of this plugin is to add go tooling support in Neovim.
|
||||
|
||||
> If you want to use new and maybe undocumented, and unstable features you might use [develop](https://github.com/olexsmir/gopher.nvim/tree/develop) branch.
|
||||
> All development of new and maybe undocumented, and unstable features is happening on [develop](https://github.com/olexsmir/gopher.nvim/tree/develop) branch.
|
||||
|
||||
## Install (using [lazy.nvim](https://github.com/folke/lazy.nvim))
|
||||
|
||||
Requirements:
|
||||
|
||||
- **Neovim 0.10** or later
|
||||
- Treesitter `go` parser(`:TSInstall go` if you use [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter))
|
||||
- [Go](https://github.com/golang/go) installed (tested on 1.23)
|
||||
- Treesitter parser for `go`(`:TSInstall go` if you use [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter))
|
||||
- [Go](https://github.com/golang/go) installed
|
||||
|
||||
```lua
|
||||
-- NOTE: this plugin is already lazy-loaded, it adds only about 1ms of load
|
||||
-- time to your config
|
||||
{
|
||||
"olexsmir/gopher.nvim",
|
||||
ft = "go",
|
||||
|
|
@ -25,58 +27,14 @@ Requirements:
|
|||
build = function()
|
||||
vim.cmd.GoInstallDeps()
|
||||
end,
|
||||
---@module "gopher"
|
||||
---@type gopher.Config
|
||||
opts = {},
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> If you need more info look `:h gopher.nvim`
|
||||
|
||||
**Take a look at default options (might be a bit outdated, look `:h gopher.nvim-config`)**
|
||||
|
||||
```lua
|
||||
require("gopher").setup {
|
||||
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
|
||||
log_level = vim.log.levels.INFO,
|
||||
|
||||
-- timeout for running internal commands
|
||||
timeout = 2000,
|
||||
|
||||
commands = {
|
||||
go = "go",
|
||||
gomodifytags = "gomodifytags",
|
||||
gotests = "gotests",
|
||||
impl = "impl",
|
||||
iferr = "iferr",
|
||||
},
|
||||
gotests = {
|
||||
-- gotests doesn't have template named "default" so this plugin uses "default" to set the default template
|
||||
template = "default",
|
||||
-- path to a directory containing custom test code templates
|
||||
template_dir = nil,
|
||||
-- switch table tests from using slice to map (with test name for the key)
|
||||
named = false,
|
||||
},
|
||||
gotag = {
|
||||
transform = "snakecase",
|
||||
-- default tags to add to struct fields
|
||||
default_tag = "json",
|
||||
},
|
||||
iferr = {
|
||||
-- choose a custom error message
|
||||
message = nil,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<!-- markdownlint-disable -->
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
<b>Install plugin's go deps</b>
|
||||
|
|
@ -99,6 +57,8 @@ require("gopher").setup {
|
|||
<b>Add and remove tags for structs via <a href="https://github.com/fatih/gomodifytags">gomodifytags</a></b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
By default `json` tag will be added/removed, if not set:
|
||||
|
||||
```vim
|
||||
|
|
@ -176,6 +136,8 @@ require("gopher").setup {
|
|||
<b>Interface implementation via <a href="https://github.com/josharian/impl">impl<a></b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
Syntax of the command:
|
||||
```vim
|
||||
:GoImpl [receiver] [interface]
|
||||
|
|
@ -199,6 +161,8 @@ require("gopher").setup {
|
|||
<b>Generate boilerplate for doc comments</b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
First set a cursor on **public** package/function/interface/struct and execute:
|
||||
|
||||
```vim
|
||||
|
|
@ -212,6 +176,8 @@ require("gopher").setup {
|
|||
<b>Generate <code>if err != nil {</code> via <a href="https://github.com/koron/iferr">iferr</a></b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
Set the cursor on the line with `err` and execute
|
||||
|
||||
```vim
|
||||
|
|
@ -219,11 +185,49 @@ require("gopher").setup {
|
|||
```
|
||||
</details>
|
||||
|
||||
## Configuration
|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> If you need more info look `:h gopher.nvim`
|
||||
|
||||
**Take a look at default options (might be a bit outdated, look `:h gopher.nvim-config`)**
|
||||
|
||||
```lua
|
||||
require("gopher").setup {
|
||||
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
|
||||
log_level = vim.log.levels.INFO,
|
||||
|
||||
-- timeout for running internal commands
|
||||
timeout = 2000,
|
||||
|
||||
commands = {
|
||||
go = "go",
|
||||
gomodifytags = "gomodifytags",
|
||||
gotests = "gotests",
|
||||
impl = "impl",
|
||||
iferr = "iferr",
|
||||
},
|
||||
gotests = {
|
||||
-- gotests doesn't have template named "default" so this plugin uses "default" to set the default template
|
||||
template = "default",
|
||||
-- path to a directory containing custom test code templates
|
||||
template_dir = nil,
|
||||
-- switch table tests from using slice to map (with test name for the key)
|
||||
named = false,
|
||||
},
|
||||
gotag = {
|
||||
transform = "snakecase",
|
||||
-- default tags to add to struct fields
|
||||
default_tag = "json",
|
||||
},
|
||||
iferr = {
|
||||
-- choose a custom error message
|
||||
message = nil,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
PRs are always welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
||||
|
||||
## Thanks
|
||||
|
||||
- [go.nvim](https://github.com/ray-x/go.nvim)
|
||||
- [iferr](https://github.com/koron/iferr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue