Skip to content

Commit

Permalink
feat(lsp_symbols): add formatter support (closes #1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Dec 17, 2024
1 parent 304253e commit 73e7f5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,9 @@ M.defaults.lsp.symbols = {
-- local align = 56 + utils.ansi_escseq_len(text)
-- return string.format("%-" .. align .. "s%s%s", text, utils.nbsp, file)
-- end,
to = false,
from = function(s, _)
-- `_from` will be called by `path.entry_to_file` *before* `from` so we
-- can combine `path.filename_first` with the symbol hardcoded formatter
_from = function(s, _)
-- restore the format to something that `path.entry_to_file` can
-- handle more robustly, while this can still work due to the `utils.nbsp`
-- it will fail when the symbol contains "[%d]" (which we use as bufnr)
Expand Down
9 changes: 7 additions & 2 deletions lua/fzf-lua/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,13 @@ end
function M.entry_to_file(entry, opts, force_uri)
opts = opts or {}
local cwd = opts.cwd
if opts._fmt and type(opts._fmt.from) == "function" then
entry = opts._fmt.from(entry, opts)
if opts._fmt then
if type(opts._fmt._from) == "function" then
entry = opts._fmt._from(entry, opts)
end
if type(opts._fmt.from) == "function" then
entry = opts._fmt.from(entry, opts)
end
end
-- Remove ansi coloring and prefixed icons
entry = utils.strip_ansi_coloring(entry)
Expand Down

0 comments on commit 73e7f5f

Please sign in to comment.