From f40b2764963de0b7c03e8ab204cbc787d688d6ed Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 5 Feb 2024 08:00:30 -0800 Subject: [PATCH] feat(lsp_live_workspace_symbols): highlight exact match (#1028) --- lua/fzf-lua/providers/lsp.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/fzf-lua/providers/lsp.lua b/lua/fzf-lua/providers/lsp.lua index 6c8a396d..8ae707e2 100644 --- a/lua/fzf-lua/providers/lsp.lua +++ b/lua/fzf-lua/providers/lsp.lua @@ -191,6 +191,12 @@ local function symbol_handler(opts, cb, _, result, _, _) if (not opts.current_buffer_only or core.CTX().bname == entry.filename) and (not opts.regex_filter or entry.text:match(opts.regex_filter)) then local mbicon_align = 0 + if opts.fn_reload and type(opts.query) == "string" and #opts.query > 0 then + -- highlight exact matches with `live_workspace_symbols` (#1028) + local sym, text = entry.text:match("^(.+%])(.*)$") + entry.text = sym .. text:gsub(utils.lua_regex_escape(opts.query), + utils.ansi_codes.red(opts.query)) + end if M._sym2style then local kind = entry.text:match("%[(.-)%]") local styled = kind and M._sym2style[kind] @@ -778,6 +784,7 @@ M.live_workspace_symbols = function(opts) -- use our own opts.func_async_callback = false opts.fn_reload = function(query) + opts.query = query opts.lsp_params = { query = query or "" } opts = gen_lsp_contents(opts) return opts.__contents