fix: typos (#82)
* docs(gotests): update and fix * fix(health): typos * docs(impl): update and fix typos * docs(config): typos * docs(iferr): update * typos * docs(struct_tags): update * docs: fix typos * docs: Capitalization * docgen
This commit is contained in:
parent
cd8a5efc88
commit
837897a79d
10 changed files with 96 additions and 86 deletions
|
|
@ -18,7 +18,6 @@ You can install these with:
|
||||||
```bash
|
```bash
|
||||||
sudo pacman -S selene stylua
|
sudo pacman -S selene stylua
|
||||||
# or whatever is your package manager
|
# or whatever is your package manager
|
||||||
# or way of installing pkgs
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For formatting use this following commands, or setup your editor to integrate with selene/stylua:
|
For formatting use this following commands, or setup your editor to integrate with selene/stylua:
|
||||||
|
|
@ -39,6 +38,7 @@ task docgen
|
||||||
```
|
```
|
||||||
|
|
||||||
### Commit messages
|
### Commit messages
|
||||||
|
|
||||||
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), please follow it.
|
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), please follow it.
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
@ -48,8 +48,5 @@ All tests live in [/spec](https://github.com/olexsmir/gopher.nvim/tree/main/spec
|
||||||
|
|
||||||
You can run tests with:
|
You can run tests with:
|
||||||
```bash
|
```bash
|
||||||
task test
|
|
||||||
# also there are some aliases for that
|
|
||||||
task tests
|
task tests
|
||||||
task spec
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ Requirements:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuratoin
|
## Configuration
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ Table of Contents
|
||||||
Setup....................................................|gopher.nvim-setup|
|
Setup....................................................|gopher.nvim-setup|
|
||||||
Install dependencies..............................|gopher.nvim-install-deps|
|
Install dependencies..............................|gopher.nvim-install-deps|
|
||||||
Configuration...........................................|gopher.nvim-config|
|
Configuration...........................................|gopher.nvim-config|
|
||||||
Modifty struct tags................................|gopher.nvim-struct-tags|
|
Modify struct tags.................................|gopher.nvim-struct-tags|
|
||||||
Auto implementation of interface methods..................|gopher.nvim-impl|
|
Auto implementation of interface methods..................|gopher.nvim-impl|
|
||||||
Generating unit tests boilerplate......................|gopher.nvim-gotests|
|
Generating unit tests boilerplate......................|gopher.nvim-gotests|
|
||||||
Iferr....................................................|gopher.nvim-iferr|
|
Iferr....................................................|gopher.nvim-iferr|
|
||||||
|
|
@ -20,7 +20,7 @@ Table of Contents
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*gopher.nvim-setup*
|
*gopher.nvim-setup*
|
||||||
`gopher.setup`({user_config})
|
`gopher.setup`({user_config})
|
||||||
Setup function. This method simply merges default configs with opts table.
|
Setup function. This method simply merges default config with opts table.
|
||||||
You can read more about configuration at |gopher.nvim-config|
|
You can read more about configuration at |gopher.nvim-config|
|
||||||
Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
|
Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ Parameters ~
|
||||||
`gopher.install_deps`
|
`gopher.install_deps`
|
||||||
Gopher.nvim implements most of its features using third-party tools.
|
Gopher.nvim implements most of its features using third-party tools.
|
||||||
To install these tools, you can run `:GoInstallDeps` command
|
To install these tools, you can run `:GoInstallDeps` command
|
||||||
or call `require("gopher").install_deps()` if you want ues lua api.
|
or call `require("gopher").install_deps()` if you want to use lua api.
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
@ -51,7 +51,7 @@ You can look at default options |gopher.nvim-config-defaults|
|
||||||
local default_config = {
|
local default_config = {
|
||||||
--minidoc_replace_end
|
--minidoc_replace_end
|
||||||
|
|
||||||
-- log level, you might consider using DEBUG or TRACE for degugging the plugin
|
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
|
||||||
---@type number
|
---@type number
|
||||||
log_level = vim.log.levels.INFO,
|
log_level = vim.log.levels.INFO,
|
||||||
|
|
||||||
|
|
@ -92,13 +92,16 @@ Class ~
|
||||||
*gopher.nvim-struct-tags*
|
*gopher.nvim-struct-tags*
|
||||||
struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields.
|
struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields.
|
||||||
Usage ~
|
Usage ~
|
||||||
- put your coursor on the struct
|
|
||||||
- run `:GoTagAdd json` to add json tags to struct fields
|
|
||||||
- run `:GoTagRm json` to remove json tags to struct fields
|
|
||||||
|
|
||||||
note: if you dont spesify the tag it will use `json` as default
|
How to add/remove tags to struct fields:
|
||||||
|
|
||||||
simple example:
|
------------------------------------------------------------------------------
|
||||||
|
2. Run `:GoTagAdd json` to add json tags to struct fields
|
||||||
|
3. Run `:GoTagRm json` to remove json tags to struct fields
|
||||||
|
|
||||||
|
NOTE: if you dont specify the tag it will use `json` as default
|
||||||
|
|
||||||
|
Example:
|
||||||
>go
|
>go
|
||||||
// before
|
// before
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|
@ -121,19 +124,25 @@ simple example:
|
||||||
impl is utilizing the `impl` tool to generate method stubs for interfaces.
|
impl is utilizing the `impl` tool to generate method stubs for interfaces.
|
||||||
Usage ~
|
Usage ~
|
||||||
|
|
||||||
1. put your coursor on the struct on which you want implement the interface
|
1. Automatically implement an interface for a struct:
|
||||||
and run `:GoImpl io.Reader`
|
- Place your cursor on the struct where you want to implement the interface.
|
||||||
which will automatically choose the reciver for the methods and
|
- Run `:GoImpl io.Reader`
|
||||||
implement the `io.Reader` interface
|
- This will automatically determine the receiver and implement the `io.Reader` interface.
|
||||||
2. same as previous but with custom receiver, so put your coursor on the struct
|
|
||||||
run `:GoImpl w io.Writer`
|
|
||||||
where `w` is the receiver and `io.Writer` is the interface
|
|
||||||
3. specift receiver, struct, and interface
|
|
||||||
there's no need to put your coursor on the struct if you specify all arguments
|
|
||||||
`:GoImpl r RequestReader io.Reader`
|
|
||||||
where `r` is the receiver, `RequestReader` is the struct and `io.Reader` is the interface
|
|
||||||
|
|
||||||
simple example:
|
2. Specify a custom receiver:
|
||||||
|
- Place your cursor on the struct
|
||||||
|
- Run `:GoImpl w io.Writer`, where:
|
||||||
|
- `w` is the receiver.
|
||||||
|
- `io.Writer` is the interface to implement.
|
||||||
|
|
||||||
|
3. Explicitly specify the receiver, struct, and interface:
|
||||||
|
- No need to place the cursor on the struct if all arguments are provided.
|
||||||
|
- Run `:GoImpl r RequestReader io.Reader`, where:
|
||||||
|
- `r` is the receiver.
|
||||||
|
- `RequestReader` is the struct.
|
||||||
|
- `io.Reader` is the interface to implement.
|
||||||
|
|
||||||
|
Example:
|
||||||
>go
|
>go
|
||||||
type BytesReader struct{}
|
type BytesReader struct{}
|
||||||
// ^ put your cursor here
|
// ^ put your cursor here
|
||||||
|
|
@ -151,30 +160,31 @@ simple example:
|
||||||
gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
|
gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
|
||||||
Usage ~
|
Usage ~
|
||||||
|
|
||||||
- generate unit test for spesisfic function/method
|
- Generate unit test for specific function/method:
|
||||||
- to specift the function/method put your cursor on it
|
1. Place your cursor on the desired function/method.
|
||||||
- run `:GoTestAdd`
|
2. Run `:GoTestAdd`
|
||||||
|
|
||||||
- generate unit tests for all functions/methods in current file
|
- Generate unit tests for *all* functions/methods in current file:
|
||||||
- run `:GoTestsAll`
|
- run `:GoTestsAll`
|
||||||
|
|
||||||
- generate unit tests only for exported(public) functions/methods
|
- Generate unit tests *only* for *exported(public)* functions/methods:
|
||||||
- run `:GoTestsExp`
|
- run `:GoTestsExp`
|
||||||
|
|
||||||
you can also specify the template to use for generating the tests. see |gopher.nvim-config|
|
You can also specify the template to use for generating the tests. See |gopher.nvim-config|
|
||||||
more details about templates can be found at: https://github.com/cweill/gotests
|
More details about templates can be found at: https://github.com/cweill/gotests
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*gopher.nvim-gotests-named*
|
*gopher.nvim-gotests-named*
|
||||||
|
|
||||||
if you prefare using named tests, you can enable it in the config.
|
You can enable named tests in the config if you prefer using named tests.
|
||||||
but you would need to install `gotests@develop` because stable version doesn't support this feature.
|
But you must install `gotests@develop` because the stable version doesn't support this feature.
|
||||||
you can do it with:
|
|
||||||
>lua
|
>lua
|
||||||
-- simply run go get in your shell:
|
-- simply run go get in your shell:
|
||||||
go install github.com/cweill/gotests/...@develop
|
go install github.com/cweill/gotests/...@develop
|
||||||
|
|
||||||
-- if you want to install it within neovim, you can use one of this:
|
-- if you want to install it within neovim, you can use one of this:
|
||||||
|
-- if you choose to install gotests this way i reocmmend adding it to your `build` section in your |lazy.nvim|
|
||||||
|
|
||||||
vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
|
vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
|
||||||
|
|
||||||
|
|
@ -186,15 +196,12 @@ you can do it with:
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*gopher.nvim-iferr*
|
*gopher.nvim-iferr*
|
||||||
if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
|
If you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
|
||||||
Usage ~
|
Usage ~
|
||||||
execute `:GoIfErr` near any err variable to insert the check
|
Execute `:GoIfErr` near any `err` variable to insert the check
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ local config = {}
|
||||||
local default_config = {
|
local default_config = {
|
||||||
--minidoc_replace_end
|
--minidoc_replace_end
|
||||||
|
|
||||||
-- log level, you might consider using DEBUG or TRACE for degugging the plugin
|
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
|
||||||
---@type number
|
---@type number
|
||||||
log_level = vim.log.levels.INFO,
|
log_level = vim.log.levels.INFO,
|
||||||
|
|
||||||
|
|
@ -66,10 +66,9 @@ local default_config = {
|
||||||
---@private
|
---@private
|
||||||
local _config = default_config
|
local _config = default_config
|
||||||
|
|
||||||
-- I am kinda secret so don't tell anyone about me
|
-- I am kinda secret so don't tell anyone about me even dont use me
|
||||||
-- even dont use me
|
|
||||||
--
|
--
|
||||||
-- if you don't belive me that i am secret see
|
-- if you don't believe me that i am secret see
|
||||||
-- the line below it says @private
|
-- the line below it says @private
|
||||||
---@private
|
---@private
|
||||||
_config.___plugin_name = "gopher.nvim" ---@diagnostic disable-line: inject-field
|
_config.___plugin_name = "gopher.nvim" ---@diagnostic disable-line: inject-field
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,31 @@
|
||||||
---@tag gopher.nvim-gotests
|
---@tag gopher.nvim-gotests
|
||||||
---@text gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
|
---@text gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
|
||||||
---@usage
|
---@usage
|
||||||
--- - generate unit test for spesisfic function/method
|
--- - Generate unit test for specific function/method:
|
||||||
--- - to specift the function/method put your cursor on it
|
--- 1. Place your cursor on the desired function/method.
|
||||||
--- - run `:GoTestAdd`
|
--- 2. Run `:GoTestAdd`
|
||||||
---
|
---
|
||||||
--- - generate unit tests for all functions/methods in current file
|
--- - Generate unit tests for *all* functions/methods in current file:
|
||||||
--- - run `:GoTestsAll`
|
--- - run `:GoTestsAll`
|
||||||
---
|
---
|
||||||
--- - generate unit tests only for exported(public) functions/methods
|
--- - Generate unit tests *only* for *exported(public)* functions/methods:
|
||||||
--- - run `:GoTestsExp`
|
--- - run `:GoTestsExp`
|
||||||
---
|
---
|
||||||
--- you can also specify the template to use for generating the tests. see |gopher.nvim-config|
|
--- You can also specify the template to use for generating the tests. See |gopher.nvim-config|
|
||||||
--- more details about templates can be found at: https://github.com/cweill/gotests
|
--- More details about templates can be found at: https://github.com/cweill/gotests
|
||||||
---
|
---
|
||||||
|
|
||||||
---@tag gopher.nvim-gotests-named
|
---@tag gopher.nvim-gotests-named
|
||||||
---@text
|
---@text
|
||||||
--- if you prefare using named tests, you can enable it in the config.
|
--- You can enable named tests in the config if you prefer using named tests.
|
||||||
--- but you would need to install `gotests@develop` because stable version doesn't support this feature.
|
--- But you must install `gotests@develop` because the stable version doesn't support this feature.
|
||||||
--- you can do it with:
|
---
|
||||||
--- >lua
|
--- >lua
|
||||||
--- -- simply run go get in your shell:
|
--- -- simply run go get in your shell:
|
||||||
--- go install github.com/cweill/gotests/...@develop
|
--- go install github.com/cweill/gotests/...@develop
|
||||||
---
|
---
|
||||||
--- -- if you want to install it within neovim, you can use one of this:
|
--- -- if you want to install it within neovim, you can use one of this:
|
||||||
|
--- -- if you choose to install gotests this way i reocmmend adding it to your `build` section in your |lazy.nvim|
|
||||||
---
|
---
|
||||||
--- vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
|
--- vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
|
||||||
---
|
---
|
||||||
|
|
@ -36,8 +37,6 @@
|
||||||
--- }
|
--- }
|
||||||
--- }
|
--- }
|
||||||
--- <
|
--- <
|
||||||
---
|
|
||||||
--- if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
|
|
||||||
|
|
||||||
local c = require "gopher.config"
|
local c = require "gopher.config"
|
||||||
local ts_utils = require "gopher._utils.ts"
|
local ts_utils = require "gopher._utils.ts"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ local u = require "gopher._utils.health_util"
|
||||||
local deps = {
|
local deps = {
|
||||||
plugin = {
|
plugin = {
|
||||||
{ lib = "dap", msg = "required for `gopher.dap`", optional = true },
|
{ lib = "dap", msg = "required for `gopher.dap`", optional = true },
|
||||||
{ lib = "plenary", msg = "required for everyting in gopher.nvim", optional = false },
|
{ lib = "plenary", msg = "required for everything in gopher.nvim", optional = false },
|
||||||
{ lib = "nvim-treesitter", msg = "required for everyting in gopher.nvim", optional = false },
|
{ lib = "nvim-treesitter", msg = "required for everything in gopher.nvim", optional = false },
|
||||||
},
|
},
|
||||||
bin = {
|
bin = {
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---@toc_entry Iferr
|
---@toc_entry Iferr
|
||||||
---@tag gopher.nvim-iferr
|
---@tag gopher.nvim-iferr
|
||||||
---@text if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
|
---@text If you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
|
||||||
---@usage execute `:GoIfErr` near any err variable to insert the check
|
---@usage Execute `:GoIfErr` near any `err` variable to insert the check
|
||||||
|
|
||||||
local c = require "gopher.config"
|
local c = require "gopher.config"
|
||||||
local log = require "gopher._utils.log"
|
local log = require "gopher._utils.log"
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,25 @@
|
||||||
---@tag gopher.nvim-impl
|
---@tag gopher.nvim-impl
|
||||||
---@text impl is utilizing the `impl` tool to generate method stubs for interfaces.
|
---@text impl is utilizing the `impl` tool to generate method stubs for interfaces.
|
||||||
---@usage
|
---@usage
|
||||||
--- 1. put your coursor on the struct on which you want implement the interface
|
--- 1. Automatically implement an interface for a struct:
|
||||||
--- and run `:GoImpl io.Reader`
|
--- - Place your cursor on the struct where you want to implement the interface.
|
||||||
--- which will automatically choose the reciver for the methods and
|
--- - Run `:GoImpl io.Reader`
|
||||||
--- implement the `io.Reader` interface
|
--- - This will automatically determine the receiver and implement the `io.Reader` interface.
|
||||||
--- 2. same as previous but with custom receiver, so put your coursor on the struct
|
|
||||||
--- run `:GoImpl w io.Writer`
|
|
||||||
--- where `w` is the receiver and `io.Writer` is the interface
|
|
||||||
--- 3. specift receiver, struct, and interface
|
|
||||||
--- there's no need to put your coursor on the struct if you specify all arguments
|
|
||||||
--- `:GoImpl r RequestReader io.Reader`
|
|
||||||
--- where `r` is the receiver, `RequestReader` is the struct and `io.Reader` is the interface
|
|
||||||
---
|
---
|
||||||
--- simple example:
|
--- 2. Specify a custom receiver:
|
||||||
|
--- - Place your cursor on the struct
|
||||||
|
--- - Run `:GoImpl w io.Writer`, where:
|
||||||
|
--- - `w` is the receiver.
|
||||||
|
--- - `io.Writer` is the interface to implement.
|
||||||
|
---
|
||||||
|
--- 3. Explicitly specify the receiver, struct, and interface:
|
||||||
|
--- - No need to place the cursor on the struct if all arguments are provided.
|
||||||
|
--- - Run `:GoImpl r RequestReader io.Reader`, where:
|
||||||
|
--- - `r` is the receiver.
|
||||||
|
--- - `RequestReader` is the struct.
|
||||||
|
--- - `io.Reader` is the interface to implement.
|
||||||
|
---
|
||||||
|
--- Example:
|
||||||
--- >go
|
--- >go
|
||||||
--- type BytesReader struct{}
|
--- type BytesReader struct{}
|
||||||
--- // ^ put your cursor here
|
--- // ^ put your cursor here
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ local gopher = {}
|
||||||
|
|
||||||
---@toc_entry Setup
|
---@toc_entry Setup
|
||||||
---@tag gopher.nvim-setup
|
---@tag gopher.nvim-setup
|
||||||
---@text Setup function. This method simply merges default configs with opts table.
|
---@text Setup function. This method simply merges default config with opts table.
|
||||||
--- You can read more about configuration at |gopher.nvim-config|
|
--- You can read more about configuration at |gopher.nvim-config|
|
||||||
--- Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
|
--- Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
|
||||||
---
|
---
|
||||||
|
|
@ -33,7 +33,7 @@ end
|
||||||
---@tag gopher.nvim-install-deps
|
---@tag gopher.nvim-install-deps
|
||||||
---@text Gopher.nvim implements most of its features using third-party tools.
|
---@text Gopher.nvim implements most of its features using third-party tools.
|
||||||
--- To install these tools, you can run `:GoInstallDeps` command
|
--- To install these tools, you can run `:GoInstallDeps` command
|
||||||
--- or call `require("gopher").install_deps()` if you want ues lua api.
|
--- or call `require("gopher").install_deps()` if you want to use lua api.
|
||||||
gopher.install_deps = require("gopher.installer").install_deps
|
gopher.install_deps = require("gopher.installer").install_deps
|
||||||
|
|
||||||
gopher.impl = require("gopher.impl").impl
|
gopher.impl = require("gopher.impl").impl
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
---@toc_entry Modifty struct tags
|
---@toc_entry Modify struct tags
|
||||||
---@tag gopher.nvim-struct-tags
|
---@tag gopher.nvim-struct-tags
|
||||||
---@text struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields.
|
---@text struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields.
|
||||||
---@usage - put your coursor on the struct
|
---@usage
|
||||||
--- - run `:GoTagAdd json` to add json tags to struct fields
|
--- How to add/remove tags to struct fields:
|
||||||
--- - run `:GoTagRm json` to remove json tags to struct fields
|
-- 1. Place cursor on the struct
|
||||||
|
--- 2. Run `:GoTagAdd json` to add json tags to struct fields
|
||||||
|
--- 3. Run `:GoTagRm json` to remove json tags to struct fields
|
||||||
---
|
---
|
||||||
--- note: if you dont spesify the tag it will use `json` as default
|
--- NOTE: if you dont specify the tag it will use `json` as default
|
||||||
---
|
---
|
||||||
--- simple example:
|
--- Example:
|
||||||
--- >go
|
--- >go
|
||||||
--- // before
|
--- // before
|
||||||
--- type User struct {
|
--- type User struct {
|
||||||
|
|
@ -74,7 +76,7 @@ local function modify(...)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- decode goted value
|
-- decode value
|
||||||
local tagged = vim.json.decode(table.concat(output))
|
local tagged = vim.json.decode(table.concat(output))
|
||||||
if
|
if
|
||||||
tagged.errors ~= nil
|
tagged.errors ~= nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue