Skip to content

Commit c501172

Browse files
committed
fix: fzf_colors booleans (closes #1582)
1 parent 2184931 commit c501172

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

lua/fzf-lua/config.lua

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,29 @@ function M.normalize_opts(opts, globals, __resume_key)
248248
-- merge with provider defaults from globals (defaults + setup options)
249249
opts = vim.tbl_deep_extend("keep", opts, utils.tbl_deep_clone(globals))
250250

251-
-- Merge required tables from globals
251+
-- Merge values from globals
252252
for _, k in ipairs({
253253
"winopts", "keymap", "fzf_opts", "fzf_colors", "fzf_tmux_opts", "hls"
254254
}) do
255-
opts[k] = vim.tbl_deep_extend("keep",
255+
local setup_val = M.globals[k]
256+
if type(setup_val) == "table" then
256257
-- must clone or map will be saved as reference
257258
-- and then overwritten if found in 'backward_compat'
258-
type(opts[k]) == "function" and opts[k]() or opts[k] or {},
259-
type(M.globals[k]) == "function" and M.globals[k](opts) or
260-
type(M.globals[k]) == "table" and utils.tbl_deep_clone(M.globals[k]) or {})
259+
setup_val = utils.tbl_deep_clone(setup_val)
260+
elseif type(setup_val) == "function" then
261+
setup_val = setup_val(opts)
262+
end
263+
if opts[k] == nil then
264+
opts[k] = setup_val
265+
else
266+
if type(opts[k]) == "function" then
267+
opts[k] = opts[k](opts)
268+
end
269+
if type(opts[k]) == "table" then
270+
opts[k] = vim.tbl_deep_extend("keep",
271+
opts[k], type(setup_val) == "table" and setup_val or {})
272+
end
273+
end
261274
end
262275

263276
-- backward compat: no-value flags should be set to `true`, in the past these

lua/fzf-lua/core.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ M.create_fzf_colors = function(opts)
534534
-- fzf_colors = {
535535
-- ["fg"] = { "fg" , { "Comment", "Normal" } }
536536
-- }
537-
colors = vim.tbl_extend("keep", colors or {},
537+
colors = vim.tbl_extend("keep", type(colors) == "table" and colors or {},
538538
vim.tbl_map(function(v)
539539
-- Value isn't guaranteed a table, e.g:
540540
-- vim.g.fzf_colors = { ["gutter"] = "-1" }
@@ -709,7 +709,7 @@ M.build_fzf_cli = function(opts, fzf_win)
709709
table.insert(cli_args, v)
710710
end
711711
end
712-
elseif opts._is_fzf_tmux == 2 and opts.__FZF_VERSION then
712+
elseif opts._is_fzf_tmux == 2 and opts.__FZF_VERSION then
713713
-- "--height" specified after "--tmux" will take priority and cause
714714
-- the job to spawn in the background without a visible interface
715715
-- NOTE: this doesn't happen with skim and will cause issues if

0 commit comments

Comments
 (0)