From 81221b6683a9424cec1f718a78124838406c6af5 Mon Sep 17 00:00:00 2001 From: "Kim A. Brandt" Date: Sat, 6 Apr 2024 03:38:41 +0200 Subject: [PATCH 1/2] fix(setup): merge configuration inside `harpoon.setup()` Instead of initializing the users configuration inside `harpoon:new()`, do it when `harpoon:setup({})` is called. This fixes the issue, when using the `settings.key`-function for the setup-call. --- lua/harpoon/init.lua | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index e34a7971..d00a87c9 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -37,18 +37,12 @@ end ---@return Harpoon function Harpoon:new() - local config = Config.get_default_config() - local harpoon = setmetatable({ - config = config, - data = Data.Data:new(config), logger = Log, - ui = Ui:new(config.settings), _extensions = Extensions.extensions, lists = {}, hooks_setup = false, }, self) - sync_on_change(harpoon) return harpoon end @@ -145,9 +139,12 @@ function Harpoon.setup(self, partial_config) end ---@diagnostic disable-next-line: param-type-mismatch - self.config = Config.merge_config(partial_config, self.config) + self.config = Config.merge_config(partial_config, Config.get_default_config()) + self.data = Data.Data:new(self.config) + self.ui = Ui:new(self.config.settings) self.ui:configure(self.config.settings) self._extensions:emit(Extensions.event_names.SETUP_CALLED, self.config) + sync_on_change(the_harpoon) ---TODO: should we go through every seen list and update its config? From a60333828a5d54467a2fd6e62f5683880817d1b1 Mon Sep 17 00:00:00 2001 From: "Kim A. Brandt" Date: Sat, 13 Apr 2024 17:05:38 +0200 Subject: [PATCH 2/2] refactor: revert and minimize some changes In order to minimize this PR, some changes have been reverted. The issue is not about merging the config, but initializing the data. --- lua/harpoon/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index d00a87c9..179e1ce3 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -37,8 +37,12 @@ end ---@return Harpoon function Harpoon:new() + local config = Config.get_default_config() + local harpoon = setmetatable({ + config = config, logger = Log, + ui = Ui:new(config.settings), _extensions = Extensions.extensions, lists = {}, hooks_setup = false, @@ -139,9 +143,8 @@ function Harpoon.setup(self, partial_config) end ---@diagnostic disable-next-line: param-type-mismatch - self.config = Config.merge_config(partial_config, Config.get_default_config()) + self.config = Config.merge_config(partial_config, self.config) self.data = Data.Data:new(self.config) - self.ui = Ui:new(self.config.settings) self.ui:configure(self.config.settings) self._extensions:emit(Extensions.event_names.SETUP_CALLED, self.config) sync_on_change(the_harpoon)