fix(config): now it works correctly
This commit is contained in:
parent
eac5560200
commit
3b0888ab10
1 changed files with 12 additions and 8 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
---@class gopher.Config
|
---@type gopher.Config
|
||||||
local config = {}
|
local config = {}
|
||||||
|
|
||||||
---@class gopher.Config
|
---@class gopher.Config
|
||||||
---@field commands gopher.ConfigCommands
|
|
||||||
local default_config = {
|
local default_config = {
|
||||||
---@class gopher.ConfigCommands
|
---@class gopher.ConfigCommand
|
||||||
commands = {
|
commands = {
|
||||||
go = "go",
|
go = "go",
|
||||||
gomodifytags = "gomodifytags",
|
gomodifytags = "gomodifytags",
|
||||||
|
|
@ -15,13 +14,18 @@ local default_config = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param user_config gopher.Config|nil
|
---@type gopher.Config
|
||||||
|
local _config = {}
|
||||||
|
|
||||||
|
---@param user_config? gopher.Config
|
||||||
function config.setup(user_config)
|
function config.setup(user_config)
|
||||||
config = vim.tbl_deep_extend("force", config, default_config, user_config or {})
|
_config = vim.tbl_deep_extend("force", default_config, user_config or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- setup ifself, needs for ability to get
|
setmetatable(config, {
|
||||||
-- default config without calling .setup()
|
__index = function(_, key)
|
||||||
config.setup()
|
return _config[key]
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue