+10
-2
README.md
+10
-2
README.md
···
130
130
131
131
8. Generate doc comment
132
132
133
-
First set a cursor on **public** package/function/interface/struct and execure:
133
+
First set a cursor on **public** package/function/interface/struct and execute:
134
134
135
135
```vim
136
136
:GoCmt
137
137
```
138
138
139
-
## Thanks:
139
+
9. Generate `if err`
140
+
141
+
Set cursor on the line with **err** and execute:
142
+
143
+
```vim
144
+
:GoIfErr
145
+
```
146
+
147
+
## Thanks
140
148
141
149
- [go.nvim](https://github.com/ray-x/go.nvim)
+1
lua/gopher/config.lua
+1
lua/gopher/config.lua
+21
lua/gopher/iferr.lua
+21
lua/gopher/iferr.lua
···
1
+
local c = require("gopher.config").config.commands
2
+
local u = require "gopher._utils"
3
+
4
+
---Add iferr declaration
5
+
---That's Lua of vimscript implementation of:
6
+
---github.com/koron/iferr
7
+
return function()
8
+
local boff = vim.fn.wordcount().cursor_bytes
9
+
local cmd = (c.iferr .. " -pos " .. boff)
10
+
local data = vim.fn.systemlist(cmd, vim.fn.bufnr "%")
11
+
12
+
if vim.v.shell_error ~= 0 then
13
+
u.notify("command " .. cmd .. " exited with code " .. vim.v.shell_error, "error")
14
+
return
15
+
end
16
+
17
+
local pos = vim.fn.getcurpos()[2]
18
+
vim.fn.append(pos, data)
19
+
vim.cmd [[silent normal! j=2j]]
20
+
vim.fn.setpos(".", pos)
21
+
end
+1
lua/gopher/init.lua
+1
lua/gopher/init.lua
···
9
9
gopher.get = require "gopher.goget"
10
10
gopher.impl = require "gopher.impl"
11
11
gopher.generate = require "gopher.gogenerate"
12
+
gopher.iferr = require "gopher.iferr"
12
13
gopher.comment = require "gopher.comment"
13
14
gopher.test_add = gotests.func_test
14
15
gopher.test_exported = gotests.all_exported_tests
+1
lua/gopher/installer.lua
+1
lua/gopher/installer.lua
+1
plugin/gopher.vim
+1
plugin/gopher.vim
···
8
8
command! -nargs=* GoImpl :lua require"gopher".impl(<f-args>)
9
9
command! -nargs=* GoGenerate :lua require"gopher".generate(<f-args>)
10
10
command! GoCmt :lua require"gopher".comment()
11
+
command! GoIfErr :lua require"gopher".iferr()
11
12
command! GoInstallDeps :lua require"gopher".install_deps()