Skip to content

Commit

Permalink
make configuration via vim global variables more consistent
Browse files Browse the repository at this point in the history
options in vim global variables no longer override:

- nested keys in `default_opts`
- `setup` `opts` with default-equivalent values
  • Loading branch information
sgvictorino committed Oct 31, 2024
1 parent 2c135f2 commit d8a8630
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lua/gitblame/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d8a8630

Please sign in to comment.