diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 11ff24d0b0..100f731564 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -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", "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* diff --git a/lua/vimtex/fzf-lua/init.lua b/lua/vimtex/fzf-lua/init.lua index 13e34887d1..ef4161e172 100644 --- a/lua/vimtex/fzf-lua/init.lua +++ b/lua/vimtex/fzf-lua/init.lua @@ -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" @@ -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)