From 27806a3359cb4413066e1f65a2a8f965189c9c96 Mon Sep 17 00:00:00 2001 From: Solomon Victorino Date: Thu, 31 Oct 2024 14:35:02 -0600 Subject: [PATCH] fix: make configuration via vim global variables more consistent options in vim global variables no longer override: - nested keys in `default_opts` - `setup` `opts` with default-equivalent values --- lua/gitblame/config.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lua/gitblame/config.lua b/lua/gitblame/config.lua index 848d8c6..3a4e1b1 100644 --- a/lua/gitblame/config.lua +++ b/lua/gitblame/config.lua @@ -27,13 +27,16 @@ M.default_opts = { ---@param opts SetupOptions? M.setup = function(opts) - opts = opts or {} - opts = vim.tbl_deep_extend("force", M.default_opts, opts) + local opts = opts or {} - for key, value in pairs(opts) do - if vim.g["gitblame_" .. key] == nil or M.default_opts[key] ~= value then - vim.g["gitblame_" .. key] = value - end + local global_var_opts = {} + for k, _ in pairs(M.default_opts) do + global_var_opts[k] = vim.g["gitblame_" .. k] + end + + opts = vim.tbl_deep_extend("force", M.default_opts, global_var_opts, opts) + for k, v in pairs(opts) do + vim.g["gitblame_" .. k] = v end end