Skip to content

Commit 3b86eef

Browse files
committed
feat(commands): added highlight groups (closes #2357)
Use `FzfLuaCmdEx|FzfLuaCmdBuf|FzfLuaCmdGlobal` to customize.
1 parent 0745fe3 commit 3b86eef

6 files changed

Lines changed: 62 additions & 6 deletions

File tree

OPTIONS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,24 @@ Type: `string`, Default: `FzfLuaLiveSym`
677677

678678
Highlight group for the matched characters in `lsp_live_workspace_symbols`.
679679

680+
#### globals.hls.cmd_global
681+
682+
Type: `string`, Default: `FzfLuaCmdGlobal`
683+
684+
Highlight group for global commands in `:FzfLua commands`, by default links to `Directory`.
685+
686+
#### globals.hls.cmd_buf
687+
688+
Type: `string`, Default: `FzfLuaCmdBuf`
689+
690+
Highlight group for buffer commands in `:FzfLua commands`, by default links to `Added`.
691+
692+
#### globals.hls.cmd_ex
693+
694+
Type: `string`, Default: `FzfLuaCmdEx`
695+
696+
Highlight group for ex commands in `:FzfLua commands`, by default links to `Statement`.
697+
680698
#### globals.hls.fzf.normal
681699

682700
Type: `string`, Default: `FzfLuaFzfNormal`

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,9 @@ temporarily overridden by its corresponding `winopts` option:
16191619
| FzfLuaFilePart | @none | `hls.file_part` | Path formatters file hl group |
16201620
| FzfLuaLivePrompt | \*PaleVioletRed1 | `hls.live_prompt` | "live" queries prompt text |
16211621
| FzfLuaLiveSym | \*PaleVioletRed1 | `hls.live_sym` | LSP live symbols query match |
1622+
| FzfLuaCmdEx | Statement | `hls.cmd_ex` | Ex commands in `commands` |
1623+
| FzfLuaCmdBuf | Added | `hls.cmd_buf` | Buffer commands in `commands` |
1624+
| FzfLuaCmdGlobal | Directory | `hls.cmd_global` | Global commands in `commands` |
16221625
| FzfLuaFzfNormal | FzfLuaNormal | `fzf.normal` | fzf's `fg\|bg` |
16231626
| FzfLuaFzfCursorLine | FzfLuaCursorLine | `fzf.cursorline` | fzf's `fg+\|bg+` |
16241627
| FzfLuaFzfMatch | Special | `fzf.match` | fzf's `hl+` |

doc/fzf-lua-opts.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*fzf-lua-opts.txt* For Neovim >= 0.8.0 Last change: 2025 June 28
1+
*fzf-lua-opts.txt* For Neovim >= 0.8.0 Last change: 2025 September 22
22

33
==============================================================================
44
Table of Contents *fzf-lua-opts-table-of-contents*
@@ -905,6 +905,33 @@ Highlight group for the matched characters in `lsp_live_workspace_symbols`.
905905

906906

907907

908+
globals.hls.cmd_global *fzf-lua-opts-globals.hls.cmd_global*
909+
910+
Type: `string`, Default: `FzfLuaCmdGlobal`
911+
912+
Highlight group for global commands in `:FzfLua commands`, by default links to
913+
`Directory`.
914+
915+
916+
917+
globals.hls.cmd_buf *fzf-lua-opts-globals.hls.cmd_buf*
918+
919+
Type: `string`, Default: `FzfLuaCmdBuf`
920+
921+
Highlight group for buffer commands in `:FzfLua commands`, by default links to
922+
`Added`.
923+
924+
925+
926+
globals.hls.cmd_ex *fzf-lua-opts-globals.hls.cmd_ex*
927+
928+
Type: `string`, Default: `FzfLuaCmdEx`
929+
930+
Highlight group for ex commands in `:FzfLua commands`, by default links to
931+
`Statement`.
932+
933+
934+
908935
globals.hls.fzf.normal *fzf-lua-opts-globals.hls.fzf.normal*
909936

910937
Type: `string`, Default: `FzfLuaFzfNormal`

lua/fzf-lua/defaults.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ M.defaults.commands = {
12311231
actions = { ["enter"] = actions.ex_run },
12321232
flatten = {},
12331233
include_builtin = true,
1234+
_cached_hls = { "cmd_ex", "cmd_buf", "cmd_global" },
12341235
}
12351236

12361237
M.defaults.autocmds = {
@@ -1456,6 +1457,9 @@ M.defaults.__HLS = {
14561457
file_part = "FzfLuaFilePart",
14571458
live_prompt = "FzfLuaLivePrompt",
14581459
live_sym = "FzfLuaLiveSym",
1460+
cmd_ex = "FzfLuaCmdEx",
1461+
cmd_buf = "FzfLuaCmdBuf",
1462+
cmd_global = "FzfLuaCmdGlobal",
14591463
fzf = {
14601464
normal = "FzfLuaFzfNormal",
14611465
cursorline = "FzfLuaFzfCursorLine",

lua/fzf-lua/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ function M.setup_highlights(override)
113113
{ default = default, fg = is_light and "CadetBlue4" or "LightSkyBlue1", bold = true } },
114114
{ "FzfLuaTabMarker", "tab_marker", -- tabs only
115115
{ default = default, fg = is_light and "MediumSpringGreen" or "BlanchedAlmond", bold = true } },
116+
-- commands
117+
{ "FzfLuaCmdEx", "cmd_ex", { default = default, link = "Statement" } },
118+
{ "FzfLuaCmdBuf", "cmd_buf", { default = default, link = "Added" } },
119+
{ "FzfLuaCmdGlobal", "cmd_global", { default = default, link = "Directory" } },
116120
-- highlight groups for `fzf_colors=true`
117121
{ "FzfLuaFzfNormal", "fzf.normal", { default = default, link = "FzfLuaNormal" } },
118122
{ "FzfLuaFzfCursorLine", "fzf.cursorline", { default = default, link = "FzfLuaCursorLine" } },

lua/fzf-lua/providers/nvim.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ M.commands = function(opts)
7474

7575
opts.flatten = opts.flatten or {}
7676
for k, _ in pairs(global_commands) do
77-
table.insert(entries, utils.ansi_codes.blue(k))
78-
add_subcommand(k, utils.ansi_codes.blue)
77+
table.insert(entries, utils.ansi_codes[opts.hls.cmd_global](k))
78+
add_subcommand(k, utils.ansi_codes.cmd_global)
7979
end
8080

8181
for k, v in pairs(buf_commands) do
8282
if type(v) == "table" then
83-
table.insert(entries, utils.ansi_codes.green(k))
84-
add_subcommand(k, utils.ansi_codes.green)
83+
table.insert(entries, utils.ansi_codes[opts.hls.cmd_buf](k))
84+
add_subcommand(k, utils.ansi_codes[opts.hls.cmd_buf])
8585
end
8686
end
8787

@@ -91,7 +91,7 @@ M.commands = function(opts)
9191
end
9292

9393
for k, _ in pairs(builtin_commands) do
94-
table.insert(entries, utils.ansi_codes.magenta(k))
94+
table.insert(entries, utils.ansi_codes[opts.hls.cmd_ex](k))
9595
end
9696

9797
opts.preview = function(args)

0 commit comments

Comments
 (0)