Skip to content

Commit 0ac5b90

Browse files
committed
fix(global): transform with-nth with fzf>= 0.69
fix #2515
1 parent 531092c commit 0ac5b90

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lua/fzf-lua/defaults.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ M.defaults.global = vim.tbl_deep_extend("force", M.defaults.files, {
557557
end)
558558
return {
559559
{ "files", desc = "Files" },
560+
-- { "blines", desc = "blines", prefix = "/" },
560561
{ "buffers", desc = "Bufs", prefix = "$" },
561562
doc_sym_supported and {
562563
"lsp_document_symbols",
@@ -591,10 +592,11 @@ M.defaults.global = vim.tbl_deep_extend("force", M.defaults.files, {
591592
},
592593
}
593594
end,
594-
fzf_opts = { ["--nth"] = false, ["--with-nth"] = false },
595+
fzf_opts = { ["--delimiter"] = "[\t]", ["--with-nth"] = ".." },
595596
winopts = { preview = { winopts = { cursorline = true } } },
596597
_ctx = { includeBuflist = true }, -- we include a buffer picker
597598
_fzf_nth_devicons = false,
599+
_treesitter = true,
598600
})
599601

600602

lua/fzf-lua/providers/meta.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ M.global = function(opts)
190190
or opts_copy)
191191
pickers[name] = def
192192
end
193+
-- HACK: inherit fzf_opts from the normalized picker opts so we have
194+
-- with-nth for the transform (e.g. for blines)
195+
-- TODO: we can probably inerit all opts but I'm not sure what would be
196+
-- the effects of that, this entire picker needs refactoring
197+
local picker_opts = config.normalize_opts(t.opts, name:gsub("^lsp_", "lsp."))
198+
if not utils.map_get(def, "opts.fzf_opts") then utils.map_set(def, "opts.fzf_opts", {}) end
199+
def.opts.fzf_opts = vim.tbl_deep_extend("force", def.opts.fzf_opts, picker_opts.fzf_opts)
193200
-- Instantiate the previewer, opts isn't guaranteed if the picker
194201
-- isn't avilable, e.g. `tags` when not tags file exists
195202
if def.opts and def.opts.previewer then
@@ -249,6 +256,14 @@ M.global = function(opts)
249256
win:redraw_preview()
250257
end
251258
reload = string.format("reload(%s)+", new_picker.contents)
259+
-- fzf >= 0.69 supports `change-with-nth` to dynamically change `--with-nth`
260+
-- dynamically update `--with-nth` per-picker (fzf >= 0.69)
261+
-- e.g. blines uses `--with-nth=4..` to hide buffer numbers
262+
if utils.has(opts, "fzf", { 0, 69 }) then
263+
-- `false|nil` defaults to all fields (..)
264+
local with_nth = utils.map_get(new_picker, "opts.fzf_opts.--with-nth")
265+
reload = reload .. string.format("change-with-nth(%s)+", with_nth or "..")
266+
end
252267
cur_sub = new_sub
253268
cur_picker = new_picker
254269
end

0 commit comments

Comments
 (0)