Skip to content

Commit f923979

Browse files
committed
feat: option to combine custom and auto fzf_colors
1 parent 1a4e693 commit f923979

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ require'fzf-lua'.setup {
735735
-- `--color fg:#010101:underline:bold`
736736
-- NOTE: to pass raw arguments `fzf_opts["--color"]` or `fzf_args`
737737
--[[ fzf_colors = {
738+
true, -- inherit fzf colors that aren't specified below from
739+
-- the auto-generated theme similar to `fzf_colors=true`
738740
["fg"] = { "fg", "CursorLine" },
739741
["bg"] = { "bg", "Normal" },
740742
["hl"] = { "fg", "Comment" },

lua/fzf-lua/config.lua

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -483,25 +483,30 @@ function M.normalize_opts(opts, globals, __resume_key)
483483

484484
-- Auto-generate fzf's colorscheme
485485
opts.fzf_colors = type(opts.fzf_colors) == "table" and opts.fzf_colors
486-
or opts.fzf_colors == true and {
487-
["fg"] = { "fg", opts.hls.fzf.normal },
488-
["bg"] = { "bg", opts.hls.fzf.normal },
489-
["hl"] = { "fg", opts.hls.fzf.match },
490-
["fg+"] = { "fg", { opts.hls.fzf.cursorline, opts.hls.fzf.normal } },
491-
["bg+"] = { "bg", opts.hls.fzf.cursorline },
492-
["hl+"] = { "fg", opts.hls.fzf.match },
493-
["info"] = { "fg", opts.hls.fzf.info },
494-
["border"] = { "fg", opts.hls.fzf.border },
495-
["gutter"] = { "bg", opts.hls.fzf.gutter },
496-
["query"] = { "fg", opts.hls.fzf.query, "regular" },
497-
["prompt"] = { "fg", opts.hls.fzf.prompt },
498-
["pointer"] = { "fg", opts.hls.fzf.pointer },
499-
["marker"] = { "fg", opts.hls.fzf.marker },
500-
["spinner"] = { "fg", opts.hls.fzf.spinner },
501-
["header"] = { "fg", opts.hls.fzf.header },
502-
["separator"] = { "fg", opts.hls.fzf.separator },
503-
["scrollbar"] = { "fg", opts.hls.fzf.scrollbar }
504-
} or {}
486+
or opts.fzf_colors == true and { true } or {}
487+
488+
if opts.fzf_colors[1] == true then
489+
opts.fzf_colors[1] = nil
490+
opts.fzf_colors = vim.tbl_deep_extend("keep", opts.fzf_colors, {
491+
["fg"] = { "fg", opts.hls.fzf.normal },
492+
["bg"] = { "bg", opts.hls.fzf.normal },
493+
["hl"] = { "fg", opts.hls.fzf.match },
494+
["fg+"] = { "fg", { opts.hls.fzf.cursorline, opts.hls.fzf.normal } },
495+
["bg+"] = { "bg", opts.hls.fzf.cursorline },
496+
["hl+"] = { "fg", opts.hls.fzf.match },
497+
["info"] = { "fg", opts.hls.fzf.info },
498+
["border"] = { "fg", opts.hls.fzf.border },
499+
["gutter"] = { "bg", opts.hls.fzf.gutter },
500+
["query"] = { "fg", opts.hls.fzf.query, "regular" },
501+
["prompt"] = { "fg", opts.hls.fzf.prompt },
502+
["pointer"] = { "fg", opts.hls.fzf.pointer },
503+
["marker"] = { "fg", opts.hls.fzf.marker },
504+
["spinner"] = { "fg", opts.hls.fzf.spinner },
505+
["header"] = { "fg", opts.hls.fzf.header },
506+
["separator"] = { "fg", opts.hls.fzf.separator },
507+
["scrollbar"] = { "fg", opts.hls.fzf.scrollbar }
508+
})
509+
end
505510

506511
-- Adjust main fzf window treesitter settings
507512
-- Disabled unless the picker is TS enabled with `_treesitter=true`

0 commit comments

Comments
 (0)