From 0d7506eb182f26df283cf652424d0d6fb5c86ec0 Mon Sep 17 00:00:00 2001 From: Leonardo Banchi Date: Tue, 1 Apr 2025 23:45:24 +0200 Subject: [PATCH 1/3] costomizable fzf options --- lua/vimtex/fzf-lua/init.lua | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) 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) From 6b1e47489bf231192299143f852b05d257138f88 Mon Sep 17 00:00:00 2001 From: Leonardo Banchi Date: Tue, 1 Apr 2025 23:50:34 +0200 Subject: [PATCH 2/3] added docs --- doc/vimtex.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 11ff24d0b0..567dbbcb30 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 pass +custom options to fzf-lua. 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* From 28c867a550571c1bd91c52c0bd921fa73d232dd5 Mon Sep 17 00:00:00 2001 From: Leonardo Banchi Date: Tue, 1 Apr 2025 23:57:50 +0200 Subject: [PATCH 3/3] fixed typos in doc --- doc/vimtex.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 567dbbcb30..100f731564 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -5438,8 +5438,8 @@ e.g. >lua return require("vimtex.fzf-lua").run() end) -Currently two options are supported: "layers" and "fzf_opts". You pass -custom options to fzf-lua. +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({layers ="cl"})`.