refactor(config): change way how it handles options

This commit is contained in:
Smirnov Oleksandr 2023-07-19 20:20:04 +03:00
parent 0c117f5230
commit 55b7304ec6

View file

@ -1,18 +1,10 @@
---@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
---@field iferr string
---@field dlv string
local M = {
---@type Config
config = {
---set custom commands for tools
commands = { commands = {
go = "go", go = "go",
gomodifytags = "gomodifytags", gomodifytags = "gomodifytags",
@ -21,13 +13,15 @@ local M = {
iferr = "iferr", iferr = "iferr",
dlv = "dlv", 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