From 3b0888ab102ef9a6abd423fc8ea470562c2d4d72 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Thu, 20 Jul 2023 19:40:12 +0300 Subject: [PATCH] fix(config): now it works correctly --- lua/gopher/config.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lua/gopher/config.lua b/lua/gopher/config.lua index e616005..b6f47d6 100644 --- a/lua/gopher/config.lua +++ b/lua/gopher/config.lua @@ -1,10 +1,9 @@ ----@class gopher.Config +---@type gopher.Config local config = {} ---@class gopher.Config ----@field commands gopher.ConfigCommands local default_config = { - ---@class gopher.ConfigCommands + ---@class gopher.ConfigCommand commands = { go = "go", 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) - config = vim.tbl_deep_extend("force", config, default_config, user_config or {}) + _config = vim.tbl_deep_extend("force", default_config, user_config or {}) end --- setup ifself, needs for ability to get --- default config without calling .setup() -config.setup() +setmetatable(config, { + __index = function(_, key) + return _config[key] + end, +}) return config