+1
-4
CONTRIBUTING.md
+1
-4
CONTRIBUTING.md
···
18
18
```bash
19
19
sudo pacman -S selene stylua
20
20
# or whatever is your package manager
21
-
# or way of installing pkgs
22
21
```
23
22
24
23
For formatting use this following commands, or setup your editor to integrate with selene/stylua:
···
39
38
```
40
39
41
40
### Commit messages
41
+
42
42
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), please follow it.
43
43
44
44
### Testing
···
48
48
49
49
You can run tests with:
50
50
```bash
51
-
task test
52
-
# also there are some aliases for that
53
51
task tests
54
-
task spec
55
52
```
+1
-1
README.md
+1
-1
README.md
+45
-38
doc/gopher.nvim.txt
+45
-38
doc/gopher.nvim.txt
···
11
11
Setup....................................................|gopher.nvim-setup|
12
12
Install dependencies..............................|gopher.nvim-install-deps|
13
13
Configuration...........................................|gopher.nvim-config|
14
-
Modifty struct tags................................|gopher.nvim-struct-tags|
14
+
Modify struct tags.................................|gopher.nvim-struct-tags|
15
15
Auto implementation of interface methods..................|gopher.nvim-impl|
16
16
Generating unit tests boilerplate......................|gopher.nvim-gotests|
17
17
Iferr....................................................|gopher.nvim-iferr|
···
20
20
------------------------------------------------------------------------------
21
21
*gopher.nvim-setup*
22
22
`gopher.setup`({user_config})
23
-
Setup function. This method simply merges default configs with opts table.
23
+
Setup function. This method simply merges default config with opts table.
24
24
You can read more about configuration at |gopher.nvim-config|
25
25
Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
26
26
···
33
33
*gopher.nvim-install-deps*
34
34
`gopher.install_deps`
35
35
Gopher.nvim implements most of its features using third-party tools.
36
-
To install these tools, you can run `:GoInstallDeps` command
37
-
or call `require("gopher").install_deps()` if you want ues lua api.
36
+
To install these tools, you can run `:GoInstallDeps` command
37
+
or call `require("gopher").install_deps()` if you want to use lua api.
38
38
39
39
40
40
==============================================================================
···
51
51
local default_config = {
52
52
--minidoc_replace_end
53
53
54
-
-- log level, you might consider using DEBUG or TRACE for degugging the plugin
54
+
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
55
55
---@type number
56
56
log_level = vim.log.levels.INFO,
57
57
···
92
92
*gopher.nvim-struct-tags*
93
93
struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields.
94
94
Usage ~
95
-
- put your coursor on the struct
96
-
- run `:GoTagAdd json` to add json tags to struct fields
97
-
- run `:GoTagRm json` to remove json tags to struct fields
95
+
96
+
How to add/remove tags to struct fields:
98
97
99
-
note: if you dont spesify the tag it will use `json` as default
98
+
------------------------------------------------------------------------------
99
+
2. Run `:GoTagAdd json` to add json tags to struct fields
100
+
3. Run `:GoTagRm json` to remove json tags to struct fields
100
101
101
-
simple example:
102
+
NOTE: if you dont specify the tag it will use `json` as default
103
+
104
+
Example:
102
105
>go
103
106
// before
104
107
type User struct {
···
121
124
impl is utilizing the `impl` tool to generate method stubs for interfaces.
122
125
Usage ~
123
126
124
-
1. put your coursor on the struct on which you want implement the interface
125
-
and run `:GoImpl io.Reader`
126
-
which will automatically choose the reciver for the methods and
127
-
implement the `io.Reader` interface
128
-
2. same as previous but with custom receiver, so put your coursor on the struct
129
-
run `:GoImpl w io.Writer`
130
-
where `w` is the receiver and `io.Writer` is the interface
131
-
3. specift receiver, struct, and interface
132
-
there's no need to put your coursor on the struct if you specify all arguments
133
-
`:GoImpl r RequestReader io.Reader`
134
-
where `r` is the receiver, `RequestReader` is the struct and `io.Reader` is the interface
127
+
1. Automatically implement an interface for a struct:
128
+
- Place your cursor on the struct where you want to implement the interface.
129
+
- Run `:GoImpl io.Reader`
130
+
- This will automatically determine the receiver and implement the `io.Reader` interface.
131
+
132
+
2. Specify a custom receiver:
133
+
- Place your cursor on the struct
134
+
- Run `:GoImpl w io.Writer`, where:
135
+
- `w` is the receiver.
136
+
- `io.Writer` is the interface to implement.
137
+
138
+
3. Explicitly specify the receiver, struct, and interface:
139
+
- No need to place the cursor on the struct if all arguments are provided.
140
+
- Run `:GoImpl r RequestReader io.Reader`, where:
141
+
- `r` is the receiver.
142
+
- `RequestReader` is the struct.
143
+
- `io.Reader` is the interface to implement.
135
144
136
-
simple example:
145
+
Example:
137
146
>go
138
147
type BytesReader struct{}
139
148
// ^ put your cursor here
···
141
150
142
151
// this is what you will get
143
152
func (b *BytesReader) Read(p []byte) (n int, err error) {
144
-
panic("not implemented") // TODO: Implement
153
+
panic("not implemented") // TODO: Implement
145
154
}
146
155
<
147
156
···
151
160
gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
152
161
Usage ~
153
162
154
-
- generate unit test for spesisfic function/method
155
-
- to specift the function/method put your cursor on it
156
-
- run `:GoTestAdd`
163
+
- Generate unit test for specific function/method:
164
+
1. Place your cursor on the desired function/method.
165
+
2. Run `:GoTestAdd`
157
166
158
-
- generate unit tests for all functions/methods in current file
167
+
- Generate unit tests for *all* functions/methods in current file:
159
168
- run `:GoTestsAll`
160
169
161
-
- generate unit tests only for exported(public) functions/methods
170
+
- Generate unit tests *only* for *exported(public)* functions/methods:
162
171
- run `:GoTestsExp`
163
172
164
-
you can also specify the template to use for generating the tests. see |gopher.nvim-config|
165
-
more details about templates can be found at: https://github.com/cweill/gotests
173
+
You can also specify the template to use for generating the tests. See |gopher.nvim-config|
174
+
More details about templates can be found at: https://github.com/cweill/gotests
166
175
167
176
------------------------------------------------------------------------------
168
177
*gopher.nvim-gotests-named*
169
178
170
-
if you prefare using named tests, you can enable it in the config.
171
-
but you would need to install `gotests@develop` because stable version doesn't support this feature.
172
-
you can do it with:
179
+
You can enable named tests in the config if you prefer using named tests.
180
+
But you must install `gotests@develop` because the stable version doesn't support this feature.
181
+
173
182
>lua
174
183
-- simply run go get in your shell:
175
184
go install github.com/cweill/gotests/...@develop
176
185
177
186
-- if you want to install it within neovim, you can use one of this:
187
+
-- if you choose to install gotests this way i reocmmend adding it to your `build` section in your |lazy.nvim|
178
188
179
189
vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
180
190
···
186
196
}
187
197
<
188
198
189
-
if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
190
-
191
-
192
199
==============================================================================
193
200
------------------------------------------------------------------------------
194
201
*gopher.nvim-iferr*
195
-
if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
202
+
If you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
196
203
Usage ~
197
-
execute `:GoIfErr` near any err variable to insert the check
204
+
Execute `:GoIfErr` near any `err` variable to insert the check
198
205
199
206
200
207
==============================================================================
+3
-4
lua/gopher/config.lua
+3
-4
lua/gopher/config.lua
···
29
29
local default_config = {
30
30
--minidoc_replace_end
31
31
32
-
-- log level, you might consider using DEBUG or TRACE for degugging the plugin
32
+
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
33
33
---@type number
34
34
log_level = vim.log.levels.INFO,
35
35
···
66
66
---@private
67
67
local _config = default_config
68
68
69
-
-- I am kinda secret so don't tell anyone about me
70
-
-- even dont use me
69
+
-- I am kinda secret so don't tell anyone about me even dont use me
71
70
--
72
-
-- if you don't belive me that i am secret see
71
+
-- if you don't believe me that i am secret see
73
72
-- the line below it says @private
74
73
---@private
75
74
_config.___plugin_name = "gopher.nvim" ---@diagnostic disable-line: inject-field
+11
-12
lua/gopher/gotests.lua
+11
-12
lua/gopher/gotests.lua
···
2
2
---@tag gopher.nvim-gotests
3
3
---@text gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
4
4
---@usage
5
-
--- - generate unit test for spesisfic function/method
6
-
--- - to specift the function/method put your cursor on it
7
-
--- - run `:GoTestAdd`
5
+
--- - Generate unit test for specific function/method:
6
+
--- 1. Place your cursor on the desired function/method.
7
+
--- 2. Run `:GoTestAdd`
8
8
---
9
-
--- - generate unit tests for all functions/methods in current file
9
+
--- - Generate unit tests for *all* functions/methods in current file:
10
10
--- - run `:GoTestsAll`
11
11
---
12
-
--- - generate unit tests only for exported(public) functions/methods
12
+
--- - Generate unit tests *only* for *exported(public)* functions/methods:
13
13
--- - run `:GoTestsExp`
14
14
---
15
-
--- you can also specify the template to use for generating the tests. see |gopher.nvim-config|
16
-
--- more details about templates can be found at: https://github.com/cweill/gotests
15
+
--- You can also specify the template to use for generating the tests. See |gopher.nvim-config|
16
+
--- More details about templates can be found at: https://github.com/cweill/gotests
17
17
---
18
18
19
19
---@tag gopher.nvim-gotests-named
20
20
---@text
21
-
--- if you prefare using named tests, you can enable it in the config.
22
-
--- but you would need to install `gotests@develop` because stable version doesn't support this feature.
23
-
--- you can do it with:
21
+
--- You can enable named tests in the config if you prefer using named tests.
22
+
--- But you must install `gotests@develop` because the stable version doesn't support this feature.
23
+
---
24
24
--- >lua
25
25
--- -- simply run go get in your shell:
26
26
--- go install github.com/cweill/gotests/...@develop
27
27
---
28
28
--- -- if you want to install it within neovim, you can use one of this:
29
+
--- -- if you choose to install gotests this way i reocmmend adding it to your `build` section in your |lazy.nvim|
29
30
---
30
31
--- vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
31
32
---
···
36
37
--- }
37
38
--- }
38
39
--- <
39
-
---
40
-
--- if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
41
40
42
41
local c = require "gopher.config"
43
42
local ts_utils = require "gopher._utils.ts"
+2
-2
lua/gopher/health.lua
+2
-2
lua/gopher/health.lua
···
5
5
local deps = {
6
6
plugin = {
7
7
{ lib = "dap", msg = "required for `gopher.dap`", optional = true },
8
-
{ lib = "plenary", msg = "required for everyting in gopher.nvim", optional = false },
9
-
{ lib = "nvim-treesitter", msg = "required for everyting in gopher.nvim", optional = false },
8
+
{ lib = "plenary", msg = "required for everything in gopher.nvim", optional = false },
9
+
{ lib = "nvim-treesitter", msg = "required for everything in gopher.nvim", optional = false },
10
10
},
11
11
bin = {
12
12
{
+2
-2
lua/gopher/iferr.lua
+2
-2
lua/gopher/iferr.lua
···
1
1
---@toc_entry Iferr
2
2
---@tag gopher.nvim-iferr
3
-
---@text if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
4
-
---@usage execute `:GoIfErr` near any err variable to insert the check
3
+
---@text If you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check.
4
+
---@usage Execute `:GoIfErr` near any `err` variable to insert the check
5
5
6
6
local c = require "gopher.config"
7
7
local log = require "gopher._utils.log"
+19
-13
lua/gopher/impl.lua
+19
-13
lua/gopher/impl.lua
···
2
2
---@tag gopher.nvim-impl
3
3
---@text impl is utilizing the `impl` tool to generate method stubs for interfaces.
4
4
---@usage
5
-
--- 1. put your coursor on the struct on which you want implement the interface
6
-
--- and run `:GoImpl io.Reader`
7
-
--- which will automatically choose the reciver for the methods and
8
-
--- implement the `io.Reader` interface
9
-
--- 2. same as previous but with custom receiver, so put your coursor on the struct
10
-
--- run `:GoImpl w io.Writer`
11
-
--- where `w` is the receiver and `io.Writer` is the interface
12
-
--- 3. specift receiver, struct, and interface
13
-
--- there's no need to put your coursor on the struct if you specify all arguments
14
-
--- `:GoImpl r RequestReader io.Reader`
15
-
--- where `r` is the receiver, `RequestReader` is the struct and `io.Reader` is the interface
5
+
--- 1. Automatically implement an interface for a struct:
6
+
--- - Place your cursor on the struct where you want to implement the interface.
7
+
--- - Run `:GoImpl io.Reader`
8
+
--- - This will automatically determine the receiver and implement the `io.Reader` interface.
16
9
---
17
-
--- simple example:
10
+
--- 2. Specify a custom receiver:
11
+
--- - Place your cursor on the struct
12
+
--- - Run `:GoImpl w io.Writer`, where:
13
+
--- - `w` is the receiver.
14
+
--- - `io.Writer` is the interface to implement.
15
+
---
16
+
--- 3. Explicitly specify the receiver, struct, and interface:
17
+
--- - No need to place the cursor on the struct if all arguments are provided.
18
+
--- - Run `:GoImpl r RequestReader io.Reader`, where:
19
+
--- - `r` is the receiver.
20
+
--- - `RequestReader` is the struct.
21
+
--- - `io.Reader` is the interface to implement.
22
+
---
23
+
--- Example:
18
24
--- >go
19
25
--- type BytesReader struct{}
20
26
--- // ^ put your cursor here
···
22
28
---
23
29
--- // this is what you will get
24
30
--- func (b *BytesReader) Read(p []byte) (n int, err error) {
25
-
--- panic("not implemented") // TODO: Implement
31
+
--- panic("not implemented") // TODO: Implement
26
32
--- }
27
33
--- <
28
34
+3
-3
lua/gopher/init.lua
+3
-3
lua/gopher/init.lua
···
17
17
18
18
---@toc_entry Setup
19
19
---@tag gopher.nvim-setup
20
-
---@text Setup function. This method simply merges default configs with opts table.
20
+
---@text Setup function. This method simply merges default config with opts table.
21
21
--- You can read more about configuration at |gopher.nvim-config|
22
22
--- Calling this function is optional, if you ok with default settings. Look |gopher.nvim.config-defaults|
23
23
---
···
32
32
---@toc_entry Install dependencies
33
33
---@tag gopher.nvim-install-deps
34
34
---@text Gopher.nvim implements most of its features using third-party tools.
35
-
--- To install these tools, you can run `:GoInstallDeps` command
36
-
--- or call `require("gopher").install_deps()` if you want ues lua api.
35
+
--- To install these tools, you can run `:GoInstallDeps` command
36
+
--- or call `require("gopher").install_deps()` if you want to use lua api.
37
37
gopher.install_deps = require("gopher.installer").install_deps
38
38
39
39
gopher.impl = require("gopher.impl").impl