+11
-5
doc/gopher.nvim.txt
+11
-5
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
+
Commands..............................................|gopher.nvim-commands|
14
15
Modify struct tags.................................|gopher.nvim-struct-tags|
15
16
Auto implementation of interface methods..................|gopher.nvim-impl|
16
17
Generating unit tests boilerplate......................|gopher.nvim-gotests|
···
36
37
Gopher.nvim implements most of its features using third-party tools.
37
38
To install these tools, you can run `:GoInstallDeps` command
38
39
or call `require("gopher").install_deps()` if you want to use lua api.
39
-
By default dependencies will be installed asynchronously, to install them synchronously pass `{sync = true}` as an argument.
40
+
By default dependencies will be installed asynchronously,
41
+
to install them synchronously pass `{sync = true}` as an argument.
40
42
41
43
42
44
==============================================================================
···
60
62
-- timeout for running internal commands
61
63
---@type number
62
64
timeout = 2000,
63
-
64
-
--- whether to setup plugin commands or not
65
-
---@type boolean
66
-
setup_commands = true,
67
65
68
66
-- user specified paths to binaries
69
67
---@class gopher.ConfigCommand
···
101
99
<
102
100
Class ~
103
101
{gopher.Config}
102
+
103
+
104
+
==============================================================================
105
+
------------------------------------------------------------------------------
106
+
*gopher.nvim-commands*
107
+
108
+
If don't want to automatically register plugins' commands,
109
+
you can set `vim.g.gopher_register_commands` to `false`, before loading the plugin.
104
110
105
111
106
112
==============================================================================
-82
lua/gopher/commands.lua
-82
lua/gopher/commands.lua
···
1
-
local commands = {}
2
-
3
-
---@param name string
4
-
---@param fn fun(args: table)
5
-
---@param nargs? number|"*"|"?"
6
-
local function cmd(name, fn, nargs)
7
-
nargs = nargs or 0
8
-
vim.api.nvim_create_user_command(name, fn, { nargs = nargs })
9
-
end
10
-
11
-
function commands.register()
12
-
cmd("GopherLog", function()
13
-
vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile())
14
-
end)
15
-
16
-
cmd("GoIfErr", function()
17
-
require("gopher").iferr()
18
-
end)
19
-
20
-
cmd("GoCmt", function()
21
-
require("gopher").comment()
22
-
end)
23
-
24
-
cmd("GoImpl", function(args)
25
-
require("gopher").impl(unpack(args.fargs))
26
-
end, "*")
27
-
28
-
-- :GoInstall
29
-
cmd("GoInstallDeps", function()
30
-
require("gopher").install_deps()
31
-
end)
32
-
33
-
cmd("GoInstallDepsSync", function()
34
-
require("gopher").install_deps { sync = true }
35
-
end)
36
-
37
-
--- :GoTag
38
-
cmd("GoTagAdd", function(opts)
39
-
require("gopher").tags.add(unpack(opts.fargs))
40
-
end, "*")
41
-
42
-
cmd("GoTagRm", function(opts)
43
-
require("gopher").tags.rm(unpack(opts.fargs))
44
-
end, "*")
45
-
46
-
cmd("GoTagClear", function()
47
-
require("gopher").tags.clear()
48
-
end)
49
-
50
-
--- :GoTest
51
-
cmd("GoTestAdd", function()
52
-
require("gopher").test.add()
53
-
end)
54
-
55
-
cmd("GoTestsAll", function()
56
-
require("gopher").test.all()
57
-
end)
58
-
59
-
cmd("GoTestsExp", function()
60
-
require("gopher").test.exported()
61
-
end)
62
-
63
-
-- :Go
64
-
cmd("GoMod", function(opts)
65
-
require("gopher").mod(opts.fargs)
66
-
end, "*")
67
-
68
-
cmd("GoGet", function(opts)
69
-
vim.print(opts)
70
-
require("gopher").get(opts.fargs)
71
-
end, "*")
72
-
73
-
cmd("GoWork", function(opts)
74
-
require("gopher").get(opts.fargs)
75
-
end, "*")
76
-
77
-
cmd("GoGenerate", function(opts)
78
-
require("gopher").generate(opts.fargs or "")
79
-
end, "?")
80
-
end
81
-
82
-
return commands
-15
lua/gopher/config.lua
-15
lua/gopher/config.lua
···
37
37
---@type number
38
38
timeout = 2000,
39
39
40
-
--- whether to setup plugin commands or not
41
-
---@type boolean
42
-
setup_commands = true,
43
-
44
40
-- user specified paths to binaries
45
41
---@class gopher.ConfigCommand
46
42
commands = {
···
97
93
vim.validate {
98
94
log_level = { _config.log_level, "number" },
99
95
timeout = { _config.timeout, "number" },
100
-
setup_commands = { _config.setup_commands, "boolean" },
101
96
["commands"] = { _config.commands, "table" },
102
97
["commands.go"] = { _config.commands.go, "string" },
103
98
["commands.gomodifytags"] = { _config.commands.gomodifytags, "string" },
···
114
109
["iferr"] = { _config.iferr, "table" },
115
110
["iferr.message"] = { _config.iferr.message, "string", true },
116
111
}
117
-
118
-
if _config.setup_commands then
119
-
require("gopher.commands").register()
120
-
end
121
-
end
122
-
123
-
---@return boolean
124
-
---@private
125
-
function config.should_setup_commands()
126
-
return config.setup_commands
127
112
end
128
113
129
114
setmetatable(config, {
+2
-1
lua/gopher/init.lua
+2
-1
lua/gopher/init.lua
···
35
35
---@text Gopher.nvim implements most of its features using third-party tools.
36
36
--- To install these tools, you can run `:GoInstallDeps` command
37
37
--- or call `require("gopher").install_deps()` if you want to use lua api.
38
-
--- By default dependencies will be installed asynchronously, to install them synchronously pass `{sync = true}` as an argument.
38
+
--- By default dependencies will be installed asynchronously,
39
+
--- to install them synchronously pass `{sync = true}` as an argument.
39
40
gopher.install_deps = require("gopher.installer").install_deps
40
41
41
42
gopher.impl = require("gopher.impl").impl
+87
plugin/gopher.lua
+87
plugin/gopher.lua
···
1
+
---@toc_entry Commands
2
+
---@tag gopher.nvim-commands
3
+
---@text
4
+
--- If don't want to automatically register plugins' commands,
5
+
--- you can set `vim.g.gopher_register_commands` to `false`, before loading the plugin.
6
+
7
+
if vim.g.gopher_register_commands == false then
8
+
return
9
+
end
10
+
11
+
---@param name string
12
+
---@param fn fun(args: table)
13
+
---@param nargs? number|"*"|"?"
14
+
---@private
15
+
local function cmd(name, fn, nargs)
16
+
nargs = nargs or 0
17
+
vim.api.nvim_create_user_command(name, fn, { nargs = nargs })
18
+
end
19
+
20
+
cmd("GopherLog", function()
21
+
vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile())
22
+
end)
23
+
24
+
cmd("GoIfErr", function()
25
+
require("gopher").iferr()
26
+
end)
27
+
28
+
cmd("GoCmt", function()
29
+
require("gopher").comment()
30
+
end)
31
+
32
+
cmd("GoImpl", function(args)
33
+
require("gopher").impl(unpack(args.fargs))
34
+
end, "*")
35
+
36
+
-- :GoInstall
37
+
cmd("GoInstallDeps", function()
38
+
require("gopher").install_deps()
39
+
end)
40
+
41
+
cmd("GoInstallDepsSync", function()
42
+
require("gopher").install_deps { sync = true }
43
+
end)
44
+
45
+
-- :GoTag
46
+
cmd("GoTagAdd", function(opts)
47
+
require("gopher").tags.add(unpack(opts.fargs))
48
+
end, "*")
49
+
50
+
cmd("GoTagRm", function(opts)
51
+
require("gopher").tags.rm(unpack(opts.fargs))
52
+
end, "*")
53
+
54
+
cmd("GoTagClear", function()
55
+
require("gopher").tags.clear()
56
+
end)
57
+
58
+
-- :GoTest
59
+
cmd("GoTestAdd", function()
60
+
require("gopher").test.add()
61
+
end)
62
+
63
+
cmd("GoTestsAll", function()
64
+
require("gopher").test.all()
65
+
end)
66
+
67
+
cmd("GoTestsExp", function()
68
+
require("gopher").test.exported()
69
+
end)
70
+
71
+
-- :Go
72
+
cmd("GoMod", function(opts)
73
+
require("gopher").mod(opts.fargs)
74
+
end, "*")
75
+
76
+
cmd("GoGet", function(opts)
77
+
vim.print(opts)
78
+
require("gopher").get(opts.fargs)
79
+
end, "*")
80
+
81
+
cmd("GoWork", function(opts)
82
+
require("gopher").get(opts.fargs)
83
+
end, "*")
84
+
85
+
cmd("GoGenerate", function(opts)
86
+
require("gopher").generate(opts.fargs or "")
87
+
end, "?")