refactor(config): change way how it handles options
This commit is contained in:
parent
0c117f5230
commit
55b7304ec6
1 changed files with 21 additions and 27 deletions
|
|
@ -1,33 +1,27 @@
|
||||||
---@class Config
|
---@class gopher.Config
|
||||||
---@field commands ConfigCommands
|
local config = {}
|
||||||
|
|
||||||
---@class ConfigCommands
|
---@class gopher.Config
|
||||||
---@field go string
|
---@field commands gopher.ConfigCommands
|
||||||
---@field gomodifytags string
|
local default_config = {
|
||||||
---@field gotests string
|
---@class gopher.ConfigCommands
|
||||||
---@field impl string
|
commands = {
|
||||||
---@field iferr string
|
go = "go",
|
||||||
---@field dlv string
|
gomodifytags = "gomodifytags",
|
||||||
|
gotests = "gotests",
|
||||||
local M = {
|
impl = "impl",
|
||||||
---@type Config
|
iferr = "iferr",
|
||||||
config = {
|
dlv = "dlv",
|
||||||
---set custom commands for tools
|
|
||||||
commands = {
|
|
||||||
go = "go",
|
|
||||||
gomodifytags = "gomodifytags",
|
|
||||||
gotests = "gotests",
|
|
||||||
impl = "impl",
|
|
||||||
iferr = "iferr",
|
|
||||||
dlv = "dlv",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---Plugin setup function
|
---@param user_config gopher.Config|nil
|
||||||
---@param opts Config user config
|
function config.setup(user_config)
|
||||||
function M.setup(opts)
|
config = vim.tbl_deep_extend("force", {}, default_config, user_config or {})
|
||||||
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
-- setup ifself, needs for ability to get
|
||||||
|
-- default config without calling .setup()
|
||||||
|
config.setup()
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue