refactor: minimize amount of vimscript (#96)
* refactor: remove autoload * since nvim 0.9 health.lua files are threaded as checkhealth provider * prof of concept * fix(runner.gocmd)!: i forgot to update it when i was working on #85 * fix(plugin): now commands register properly * fix(plugin): fix command name for :GoIfErr * fix(plugin): respect `setup_commands` option * docs: update * refactor(plugin): use vim.schedule * docs: update CONTRIBUTING
This commit is contained in:
parent
c5cc5080fa
commit
9aa0038125
9 changed files with 108 additions and 50 deletions
|
|
@ -25,9 +25,9 @@ end
|
|||
|
||||
---@param subcmd string
|
||||
---@param args string[]
|
||||
---@return string[]|nil
|
||||
---@return string
|
||||
function gocmd.run(subcmd, args)
|
||||
if #args == 0 then
|
||||
if #args == 0 and subcmd ~= "generate" then
|
||||
error "please provide any arguments"
|
||||
end
|
||||
|
||||
|
|
@ -39,15 +39,13 @@ function gocmd.run(subcmd, args)
|
|||
args = if_generate(args)
|
||||
end
|
||||
|
||||
return r.sync(c.go, {
|
||||
args = { subcmd, unpack(args) },
|
||||
on_exit = function(data, status)
|
||||
if status ~= 0 then
|
||||
error("gocmd failed: " .. data)
|
||||
end
|
||||
u.notify(c.go .. " " .. subcmd .. " ran successful")
|
||||
end,
|
||||
})
|
||||
local rs = r.sync { c.go, subcmd, unpack(args) }
|
||||
if rs.code ~= 0 then
|
||||
error("go " .. subcmd .. " failed: " .. rs.stderr)
|
||||
end
|
||||
|
||||
u.notify(c.go .. " " .. subcmd .. " ran successful")
|
||||
return rs.stdout
|
||||
end
|
||||
|
||||
return gocmd
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ local default_config = {
|
|||
---@type number
|
||||
timeout = 2000,
|
||||
|
||||
--- whether to setup plugin commands or not
|
||||
---@type boolean
|
||||
setup_commands = true,
|
||||
|
||||
-- user specified paths to binaries
|
||||
---@class gopher.ConfigCommand
|
||||
commands = {
|
||||
|
|
@ -90,10 +94,18 @@ function config.setup(user_config)
|
|||
_config = vim.tbl_deep_extend("force", default_config, user_config or {})
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
---@private
|
||||
function config.should_setup_commands()
|
||||
return config.setup_commands
|
||||
end
|
||||
|
||||
setmetatable(config, {
|
||||
__index = function(_, key)
|
||||
return _config[key]
|
||||
end,
|
||||
})
|
||||
|
||||
---@return gopher.Config
|
||||
---@private
|
||||
return config
|
||||
|
|
|
|||
|
|
@ -55,19 +55,19 @@ gopher.test = {
|
|||
}
|
||||
|
||||
gopher.get = function(...)
|
||||
gocmd("get", { ... })
|
||||
gocmd("get", ...)
|
||||
end
|
||||
|
||||
gopher.mod = function(...)
|
||||
gocmd("mod", { ... })
|
||||
gocmd("mod", ...)
|
||||
end
|
||||
|
||||
gopher.generate = function(...)
|
||||
gocmd("generate", { ... })
|
||||
gocmd("generate", ...)
|
||||
end
|
||||
|
||||
gopher.work = function(...)
|
||||
gocmd("work", { ... })
|
||||
gocmd("work", ...)
|
||||
end
|
||||
|
||||
return gopher
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue