Skip to content

Commit

Permalink
fix(formatter): disable in tags|lsp_symbols, fix blines
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed May 5, 2024
1 parent e627782 commit 43f46c4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lua/fzf-lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,12 @@ function M.normalize_opts(opts, globals, __resume_key)
local _fmt = M.globals["formatters." .. opts.formatter]
if _fmt then
opts._fmt = opts._fmt or {}
opts._fmt.to = opts._fmt.to or _fmt.to or _fmt._to and _fmt._to(opts) or nil
opts._fmt.from = opts._fmt.from or _fmt.from
if opts._fmt.to == nil then
opts._fmt.to = _fmt.to or _fmt._to and _fmt._to(opts) or nil
end
if opts._fmt.from == nil then
opts._fmt.from = _fmt.from
end
if type(opts._fmt.to) == "string" then
-- store the string function as backup for `make_entry.preprocess`
opts._fmt._to = opts._fmt.to
Expand Down
1 change: 1 addition & 0 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ 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, _)
-- restore the format to something that `path.entry_to_file` can
-- handle more robustly, while this can stil work due to the `utils.nbsp`
Expand Down
4 changes: 3 additions & 1 deletion lua/fzf-lua/providers/buffers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ end
M.buffer_lines = function(opts)
if not opts then return end

-- set parent_idx base for `formatter=path.filename_first`
opts._parent_idx = 3

opts.fn_pre_fzf = function() core.CTX(true) end
opts.fn_pre_fzf()

Expand Down Expand Up @@ -295,7 +298,6 @@ M.buffer_lines = function(opts)
end

opts = core.set_fzf_field_index(opts, "{3}", opts._is_skim and "{}" or "{..-2}")

core.fzf_exec(contents, opts)
end

Expand Down
2 changes: 1 addition & 1 deletion lua/fzf-lua/providers/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ local function symbol_handler(opts, cb, _, result, _, _)
symbol = symbol .. string.rep(" ", align - #symbol)
end
entry = symbol .. utils.nbsp .. entry
cb(opts._fmt and opts._fmt.to and opts._fmt.to(entry, opts) or entry)
cb(entry)
end
end
end
Expand Down
7 changes: 5 additions & 2 deletions lua/fzf-lua/providers/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ local function tags(opts)
local cmd, filter = get_tags_cmd({ search = "dummy" })
if not cmd then return end -- cmd only used for this test
opts.filter = (opts.filter == nil) and filter or opts.filter
-- rg globs are meaningless here since we are searching
-- a single file
-- rg globs are meaningless here since we are searching a single file
opts.rg_glob = false
-- tags has it's own formatter
opts.formatter, opts._fmt = false, { _to = false, to = false, from = false }
opts.filename = opts._ctags_file
if opts.multiprocess then
return require "fzf-lua.providers.grep".live_grep_mt(opts)
Expand All @@ -181,6 +182,8 @@ local function tags(opts)
if opts.filter and #opts.filter > 0 then
opts.raw_cmd = ("%s | %s"):format(opts.raw_cmd, opts.filter)
end
-- tags has it's own formatter
opts.formatter, opts._fmt = false, { _to = false, to = false, from = false }
return require "fzf-lua.providers.grep".grep(opts)
end
end
Expand Down

0 comments on commit 43f46c4

Please sign in to comment.