Skip to content

Commit

Permalink
feat(lsp_live_workspace_symbols): highlight exact match (#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Feb 5, 2024
1 parent 8ab5d68 commit f40b276
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/fzf-lua/providers/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f40b276

Please sign in to comment.