Skip to content

Commit 8d24d4c

Browse files
committed
merge: more customizable fzf-lua
refer: lervag#3140
2 parents 1a47896 + 28c867a commit 8d24d4c

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

doc/vimtex.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5431,16 +5431,18 @@ FZF-LUA INTEGRATION *vimtex-fzf-lua*
54315431
https://github.com/ibhagwan/fzf-lua/
54325432
|fzf-lua| integrates the general-purpose command-line fuzzy finder |fzf| into
54335433
neovim through Lua. It may be used to quickly navigate VimTeX's built-in ToC
5434-
feature. To use it, define a mapping to `require("vimtex.fzf-lua").run()`,
5434+
feature. To use it, define a mapping to `require("vimtex.fzf-lua").run(options)`,
54355435
e.g. >lua
54365436

54375437
vim.keymap.set("n", "<localleader>lt", function()
54385438
return require("vimtex.fzf-lua").run()
54395439
end)
54405440

5441+
Currently two options are supported: "layers" and "fzf_opts". You can pass
5442+
custom options to fzf-lua via "fzf_opts".
54415443
You can also choose to only show certain entry "layers" by passing a layer
54425444
string. By default, all layers are displayed. To only show `content` and
5443-
`label`s use `require("vimtex.fzf-lua").run("cl")`.
5445+
`label`s use `require("vimtex.fzf-lua").run({layers ="cl"})`.
54445446

54455447
==============================================================================
54465448
COMPILER *vimtex-compiler*

lua/vimtex/fzf-lua/init.lua

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ end
4242

4343
---Runs fzf-lua to select and navigate to from a list of TOC items.
4444
---
45-
---@param layers string? The layers to filter. Can be a substring of `ctli`
46-
--- corresponding to content, todos, labels, and includes.
45+
---@param options table? Available options:
46+
--- - layers: The layers to filter. Can be a substring of `ctli`
47+
--- corresponding to content, todos, labels, and includes.
48+
--- - fzf_opts: list of options for fzf_exec
4749
---@return nil
48-
M.run = function(layers)
49-
if layers == nil then
50-
layers = "ctli"
50+
M.run = function(options)
51+
local layers = "ctli"
52+
if options ~= nil and options["layers"] ~= nil then
53+
layers = options["layers"]
54+
options["layers"] = nil
5155
end
5256

5357
local fzf = require "fzf-lua"
@@ -68,11 +72,16 @@ M.run = function(layers)
6872
)
6973
end, entries)
7074

75+
local fzfoptions = {
76+
["--delimiter"] = "####",
77+
["--with-nth"] = "{2} {3}",
78+
}
79+
if options ~= nil and options["fzf_opts"] ~= nil then
80+
fzfoptions = vim.tbl_extend('force', fzfoptions, options["fzf_opts"])
81+
end
82+
7183
fzf.fzf_exec(fzf_entries, {
72-
fzf_opts = {
73-
["--delimiter"] = "####",
74-
["--with-nth"] = "{2} {3}",
75-
},
84+
fzf_opts = fzfoptions,
7685
actions = {
7786
default = function(selection, o)
7887
local s = vim.tbl_map(function(t)

0 commit comments

Comments
 (0)