Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5431,16 +5431,18 @@ FZF-LUA INTEGRATION *vimtex-fzf-lua*
https://github.com/ibhagwan/fzf-lua/
|fzf-lua| integrates the general-purpose command-line fuzzy finder |fzf| into
neovim through Lua. It may be used to quickly navigate VimTeX's built-in ToC
feature. To use it, define a mapping to `require("vimtex.fzf-lua").run()`,
feature. To use it, define a mapping to `require("vimtex.fzf-lua").run(options)`,
e.g. >lua

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

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

==============================================================================
COMPILER *vimtex-compiler*
Expand Down
27 changes: 18 additions & 9 deletions lua/vimtex/fzf-lua/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ end

---Runs fzf-lua to select and navigate to from a list of TOC items.
---
---@param layers string? The layers to filter. Can be a substring of `ctli`
--- corresponding to content, todos, labels, and includes.
---@param options table? Available options:
--- - layers: The layers to filter. Can be a substring of `ctli`
--- corresponding to content, todos, labels, and includes.
--- - fzf_opts: list of options for fzf_exec
---@return nil
M.run = function(layers)
if layers == nil then
layers = "ctli"
M.run = function(options)
local layers = "ctli"
if options ~= nil and options["layers"] ~= nil then
layers = options["layers"]
options["layers"] = nil
end

local fzf = require "fzf-lua"
Expand All @@ -68,11 +72,16 @@ M.run = function(layers)
)
end, entries)

local fzfoptions = {
["--delimiter"] = "####",
["--with-nth"] = "{2} {3}",
}
if options ~= nil and options["fzf_opts"] ~= nil then
fzfoptions = vim.tbl_extend('force', fzfoptions, options["fzf_opts"])
end

fzf.fzf_exec(fzf_entries, {
fzf_opts = {
["--delimiter"] = "####",
["--with-nth"] = "{2} {3}",
},
fzf_opts = fzfoptions,
actions = {
default = function(selection, o)
local s = vim.tbl_map(function(t)
Expand Down