fix(plugin): respect setup_commands option
This commit is contained in:
parent
b49175cd34
commit
eeff227715
2 changed files with 66 additions and 56 deletions
|
|
@ -93,10 +93,17 @@ function config.setup(user_config)
|
||||||
_config = vim.tbl_deep_extend("force", default_config, user_config or {})
|
_config = vim.tbl_deep_extend("force", default_config, user_config or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return boolean
|
||||||
|
---@private
|
||||||
|
function config.should_setup_commands()
|
||||||
|
return config.setup_commands
|
||||||
|
end
|
||||||
|
|
||||||
setmetatable(config, {
|
setmetatable(config, {
|
||||||
__index = function(_, key)
|
__index = function(_, key)
|
||||||
return _config[key]
|
return _config[key]
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
---@return gopher.Config
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@ if vim.g.gopher_loaded == 1 then
|
||||||
end
|
end
|
||||||
vim.g.gopher_loaded = 1
|
vim.g.gopher_loaded = 1
|
||||||
|
|
||||||
local c = require "gopher.config"
|
--- NOTE: runs in defer since this file before gopher.config
|
||||||
if c.setup_commands then
|
--- I'm not sure if this is the best to do this
|
||||||
|
vim.defer_fn(function()
|
||||||
|
if require("gopher.config").should_setup_commands() then
|
||||||
vim.api.nvim_create_user_command("GopherLog", function()
|
vim.api.nvim_create_user_command("GopherLog", function()
|
||||||
vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile())
|
vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile())
|
||||||
end, { nargs = 0 })
|
end, { nargs = 0 })
|
||||||
|
|
@ -73,4 +75,5 @@ if c.setup_commands then
|
||||||
vim.api.nvim_create_user_command("GoGenerate", function(opts)
|
vim.api.nvim_create_user_command("GoGenerate", function(opts)
|
||||||
require("gopher").generate(opts.fargs or "")
|
require("gopher").generate(opts.fargs or "")
|
||||||
end, { nargs = "?" })
|
end, { nargs = "?" })
|
||||||
end
|
end
|
||||||
|
end, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue