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 {})
|
||||
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
|
||||
return config
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ if vim.g.gopher_loaded == 1 then
|
|||
end
|
||||
vim.g.gopher_loaded = 1
|
||||
|
||||
local c = require "gopher.config"
|
||||
if c.setup_commands then
|
||||
--- NOTE: runs in defer since this file before gopher.config
|
||||
--- 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.cmd("tabnew " .. require("gopher._utils.log").get_outfile())
|
||||
end, { nargs = 0 })
|
||||
|
|
@ -74,3 +76,4 @@ if c.setup_commands then
|
|||
require("gopher").generate(opts.fargs or "")
|
||||
end, { nargs = "?" })
|
||||
end
|
||||
end, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue