### Setup fzf-lua with combined profiles and custom window options Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md This example demonstrates combining multiple profiles ('telescope' and 'fzf-native') and applying custom window options, such as making the window fullscreen. This allows for highly tailored configurations. ```lua :lua require"fzf-lua".setup({{"telescope","fzf-native"},winopts={fullscreen=true}}) ``` -------------------------------- ### Setup fzf-lua with fzf-native profile Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Use this to set up fzf-lua with the 'fzf-native' profile. This is a quick way to get started with a specific configuration. ```lua require('fzf-lua').setup({'fzf-native'}) ``` -------------------------------- ### Customize FzfLua Setup with Profile and Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/lua/fzf-lua/profiles/README.md Use a profile as a baseline and apply custom options, such as setting the previewer. This example uses the 'telescope' profile with 'bat' for previews. ```lua :lua require"fzf-lua".setup({"telescope",winopts={preview={default="bat"}}}) ``` -------------------------------- ### Setup FzfLua with a Profile Source: https://github.com/ibhagwan/fzf-lua/blob/main/lua/fzf-lua/profiles/README.md Call the setup function with a profile name as a string to activate it. This can be done multiple times for live switching. ```lua require("fzf-lua").setup({ "fzf-native" }) ``` -------------------------------- ### Setup and Call fzf-lua Providers Source: https://github.com/ibhagwan/fzf-lua/wiki/Options Demonstrates how to set default options for all function calls using `setup` or specific options for a single function call like `files`. ```lua require'fzf-lua'.setup { ... } -- or specific setting for a single function call require'fzf-lua'.files { prompt = "Search files > " } ``` -------------------------------- ### Setup fzf-lua with Global Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Configure fzf-lua by passing a table of options to the setup function. This includes UI, keymap, actions, fzf CLI flags, and color specifications. ```lua require("fzf-lua").setup { -- MISC GLOBAL SETUP OPTIONS, SEE BELOW -- fzf_bin = ..., -- each of these options can also be passed as function that return options table -- e.g. winopts = function() return { ... } end winopts = { ... }, keymap = { ... }, actions = { ... }, fzf_opts = { ... }, fzf_colors = { ... }, hls = { ... }, previewers = { ... }, -- SPECIFIC COMMAND/PICKER OPTIONS, SEE BELOW -- files = { ... }, } ``` -------------------------------- ### Vim-plug Setup for fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Use this configuration with vim-plug to install fzf-lua and nvim-web-devicons. ```vim Plug 'ibhagwan/fzf-lua' Plug 'kyazdani42/nvim-web-devicons' ``` -------------------------------- ### Configure Buffer Provider Options in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Options Example of how to set various buffer provider options within the fzf-lua setup function. This includes filtering by directory, ignoring the current buffer, showing unloaded buffers, and controlling terminal buffer inclusion. ```lua require'fzf-lua'.setup { files = { cwd = '~/.config', ... }, buffers = { ignore_current_buffer = true, show_unloaded = true, cwd_only = false, cwd = nil, ... }, blines = { no_term_buffers = false, ... }, tabs = { show_unlisted = true, current_tab_only = true, ... }, } ``` -------------------------------- ### Run fzf.lua Quickstart Script Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Execute this command to quickly test the plugin without modifying your Neovim configuration. It runs in a sandbox environment with default keybinds. ```shell sh -c "$(curl -s https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/mini.sh)" ``` -------------------------------- ### Install fzf.lua with lazy.nvim Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Use this Lua configuration snippet with lazy.nvim to install fzf-lua. Optionally include nvim-web-devicons or mini.icons for icon support. ```lua { "ibhagwan/fzf-lua", -- optional for icon support dependencies = { "nvim-tree/nvim-web-devicons" }, -- or if using mini.icons/mini.nvim -- dependencies = { "nvim-mini/mini.icons" }, ---@module "fzf-lua" ---@type fzf-lua.Config|{} ---@diagnostic disable: missing-fields opts = {} ---@diagnostic enable: missing-fields } ``` -------------------------------- ### Packer.nvim Setup for fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Use this configuration with packer.nvim to install fzf-lua and nvim-web-devicons. ```lua use { 'ibhagwan/fzf-lua', requires = { 'kyazdani42/nvim-web-devicons' }, } ``` -------------------------------- ### Setup fzf-lua with Automatic Colors Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Enable automatic generation of fzf colorscheme from the current Neovim colorscheme. This is a global setup option. ```lua require("fzf-lua").setup({ fzf_colors = true }) ``` -------------------------------- ### Install fzf-lua with lazy.nvim Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt This Lua code snippet demonstrates how to install the fzf-lua plugin using the lazy.nvim package manager. Optional configuration for icon support is also included. ```lua { "ibhagwan/fzf-lua", -- optional for icon support ``` -------------------------------- ### Global Setup Options for fzf-lua Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Customize global behavior like specifying an alternative binary (e.g., 'sk' for skim) or handling file icon padding for specific terminal emulators. ```lua -- Use skim (or a speccific fzf binary/version) instead of fzf? -- fzf_bin = 'sk', -- Padding can help kitty term users with double-width icon rendering file_icon_padding = '', -- Uncomment if your terminal/font does not support unicode character -- 'EN SPACE' (U+2002), the below sets it to 'NBSP' (U+00A0) instead -- nbsp = '\xc2\xa0', -- Function override for opening the help window (default bound to ``) -- Override this function if you want to customize window config of the -- help window (location, width, border, etc.) help_open_win = vim.api.nvim_open_win, ``` -------------------------------- ### Setup: Default Previewer for File Pickers Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua-opts.txt Sets the default previewer for file pickers to 'bat'. Other options include 'builtin', 'cat', or 'head'. Can also be a function or an object for advanced customization. ```lua require("fzf-lua").setup({ winopts = { preview = { default = "bat" } } }) ``` -------------------------------- ### Setup fzf-lua with fzf-vim profile Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Use this to set up fzf-lua with the 'fzf-vim' profile, which closely matches the defaults of fzf.vim. This profile also automatically sets up fzf.vim's user commands like :Files and :Rg. ```lua require('fzf-lua').setup({'fzf-vim'}) ``` -------------------------------- ### Setup fzf-lua with Automatic Color Generation Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Enable automatic generation of an fzf colorscheme from your current Neovim colorscheme by setting `fzf_colors` to `true` in the setup function. ```lua require("fzf-lua").setup({ fzf_colors = true }) -- Or in the direct call options :lua FzfLua.files({ fzf_colors = true }) :FzfLua files fzf_colors=true ``` -------------------------------- ### Combining fzf-lua Pickers Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Demonstrates how to combine multiple fzf-lua pickers into a single display using the `combine` method. The example combines `oldfiles` and `git_files`. Options from the first picker apply to all. ```lua :lua FzfLua.combine({ pickers = "oldfiles;git_files" }) -- or using the `FzfLua` vim command: :FzfLua combine pickers=oldfiles;git_files ``` -------------------------------- ### Example: Action resume converted to reload Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Demonstrates how an action defined with 'actions.resume' can be automatically converted to a 'reload' action when the conditions are met, allowing for smoother UI updates. ```lua require'fzf-lua'.fzf_exec("ls", { actions = { ['ctrl-x'] = { fn = function(selected) for _, f in ipairs(selected) do print("deleting:", f) -- uncomment to enable deletion -- vim.fn.delete(f) end end, reload = true, } } }) ``` -------------------------------- ### Extend Builtin Previewer for Custom Entry Parsing Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Provides an example of extending the 'buffer_or_file' previewer to parse custom entry formats like 'file:line'. ```lua local fzf_lua = require("fzf-lua") local builtin = require("fzf-lua.previewer.builtin") -- Inherit from the "buffer_or_file" previewer local MyPreviewer = builtin.buffer_or_file:extend() function MyPreviewer:new(o, opts, fzf_win) MyPreviewer.super.new(self, o, opts, fzf_win) setmetatable(self, MyPreviewer) return self end function MyPreviewer:parse_entry(entry_str) -- Assume an arbitrary entry in the format of 'file:line' local path, line = entry_str:match("([^:]+):?(.*)") return { path = path, line = tonumber(line) or 1, col = 1, } end fzf_lua.fzf_exec("rg --files", { previewer = MyPreviewer, prompt = "Select file> ", }) ``` -------------------------------- ### Setup fzf-lua with fzf-native and hide profiles Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md This setup combines the 'fzf-native' and 'hide' profiles. The 'hide' profile ensures that pressing 'Esc' backgrounds the fzf process instead of terminating it, allowing for better resume functionality. ```lua require("fzf-lua").setup({ { "fzf-native", "hide" }, -- your other settings here }) ``` -------------------------------- ### Set Custom Path Formatter Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Demonstrates setting a custom path formatter, such as `path.filename_first`, for the `files` and `live_grep` pickers. This can be set temporarily or permanently via `setup`. ```lua :FzfLua files formatter=path.filename_first ``` ```lua :FzfLua live_grep formatter=path.filename_first ``` ```lua require("fzf-lua").setup({ files = { formatter = "path.filename_first" } }) ``` -------------------------------- ### Configure fzf-lua Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Example configuration for fzf-lua options related to diagnostics, marks, and path completion. These settings control how information is displayed and how completion commands behave. ```lua diag_source = true, diag_code = true, icon_padding = '', multiline = 2, }, marks = { marks = "", }, complete_path = { cmd = nil, complete = { ["enter"] = actions.complete }, word_pattern = nil, }, complete_file = { cmd = nil, file_icons = true, color_icons = true, word_pattern = nil, actions = { ["enter"] = actions.complete }, winopts = { preview = { hidden = true } }, }, zoxide = { cmd = "zoxide query --list --score", scope = "global", git_root = false, formatter = "path.dirname_first", fzf_opts = { ["--no-multi"] = true, ["--delimiter"] = "[ ]", ["--tabstop"] = "4", ["--tiebreak"] = "end,index", ["--nth"] = "2..", }, actions = { enter = actions.cd } } ``` -------------------------------- ### Live Grep Glob Example Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Initiate a live grep search that supports glob patterns. Use the specified separator to append glob specifications to your search query. ```sh Rg> -- ... ``` -------------------------------- ### Live Query with Lua Table Contents Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Example of using fzf_live with a Lua table as content. The table is generated dynamically based on the user's input query, demonstrating live updates. ```lua require 'fzf-lua'.fzf_live( function(args) local q = args[1] if not tonumber(q) then return { "Invalid number: " .. tostring(q) } end local lines = {} for i = 1, tonumber(q) do table.insert(lines, tostring(i)) end return lines end, { prompt = 'Live> ', exec_empty_query = true, } ) ``` -------------------------------- ### Configure fd options for files provider Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Provider-specific options, like `fd_opts` for the `files` provider, can be set in the `setup` function to modify default command-line arguments, such as excluding directories. ```lua -- Note the omission of `fd`: :lua require'fzf-lua'.files({ fd_opts = '--type f --exclude node_modules' }) ``` -------------------------------- ### Glob Search for Test Files Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Example of searching for a library import within files matching a specific test file pattern (`.spec.`). ```sh Rg> @testing-library/react-hooks --*.spec.* ``` -------------------------------- ### Map Super Key to Ctrl-u in fzf Previewer Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Use the `winopts.on_create` callback to define custom buffer mappings. This example maps the Super/Meta key + Backspace to Ctrl-u within the fzf previewer. ```lua fzf_lua.setup({ winopts = { on_create = function() -- creates a local buffer mapping translating to vim.keymap.set("t", "", "lua vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, false, true), 'n', true)", {nowait = true, buffer = true}) end } }) ``` -------------------------------- ### Dynamic Window Sizing with winopts_fn in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Implement dynamic window sizing by defining 'winopts_fn' as a function that returns a table of 'winopts' parameters. This example adjusts width based on Neovim's column count. ```lua require("fzf-lua").setup({ winopts_fn = function() return { width = vim.o.columns>80 and 0.65 or 0.85 } end, }) ``` -------------------------------- ### Configure Separate History Files per Provider Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Define distinct history files for specific providers like `files` and `grep` by configuring `fzf_opts` within each provider's setup table. ```lua require('fzf-lua').setup{ files = { fzf_opts = { ['--history'] = vim.fn.stdpath("data") .. '/fzf-lua-files-history', }, }, grep = { fzf_opts = { ['--history'] = vim.fn.stdpath("data") .. '/fzf-lua-grep-history', }, } } ``` -------------------------------- ### Configure fzf-tmux Wrapper Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Shows how to pass options to the `fzf-tmux` wrapper using the `fzf_tmux_opts` global option, like setting the margin and popup size. ```lua require("fzf-lua").setup({ fzf_tmux_opts = { ["--margin"] = "0,0", ["-p"] = "80%,80%" } }) ``` -------------------------------- ### Configure Highlight Groups via fzf-lua Setup Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Configures highlight groups for fzf-lua by setting the 'border' highlight to 'FloatBorder' within the `setup` function. ```lua require('fzf-lua').setup { hls = { border = "FloatBorder" } } ``` -------------------------------- ### Basic Fzf Native Preview with Cat Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Sets up a basic file listing with a 'cat' command for previewing. Note that when supplying a preview command through `fzf_opts`, it needs to be shell escaped. ```lua require'fzf-lua'.fzf_exec("rg --files", { preview = "cat {}", fzf_opts = { ['--preview-window'] = 'nohidden,down,50%' }, }) ``` ```lua require'fzf-lua'.fzf_exec("rg --files", { fzf_opts = { ['--preview'] = "cat {}", ['--preview-window'] = 'nohidden,down,50%', }, }) ``` -------------------------------- ### Run Minimal Init Script Source: https://github.com/ibhagwan/fzf-lua/wiki/Home This shell command downloads the minimal_init.lua script and then runs Neovim using it as the configuration file. ```sh curl -LO https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/minimal_init.lua nvim -u minimal_init.lua ``` -------------------------------- ### Configure fzf-lua border highlight group via setup Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Set the FzfLuaBorder highlight group using the hls.border option within the fzf-lua setup function for global configuration. ```lua require('fzf-lua').setup { hls = { border = "FloatBorder" } } ``` -------------------------------- ### Use Builtin Previewer for Files Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Demonstrates using the default 'builtin' previewer to display files found by 'rg --files'. ```lua :lua require'fzf-lua'.fzf_exec("rg --files", { previewer = "builtin" }) ``` -------------------------------- ### Live RG Matches with Builtin Previewer Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Shows how to use the 'builtin' previewer with live 'rg' matches, including line and column information. ```lua :lua require'fzf-lua'.fzf_live("rg --column --color=always", { previewer = "builtin" }) ``` -------------------------------- ### Inline Customization: Fzf Layout Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Modify the fzf layout using inline parameters. This example sets the layout to 'reverse-list'. ```lua :lua FzfLua.files({ fzf_opts = {['--layout'] = 'reverse-list'} }) ``` ```vim :FzfLua files fzf_opts.--layout=reverse-list ``` -------------------------------- ### Run Minimal Init Script Directly from GitHub Source: https://github.com/ibhagwan/fzf-lua/wiki/Home This command executes Neovim with a configuration that streams the minimal_init.lua script directly from GitHub using process substitution. ```sh nvim -u <((echo "lua << EOF") && (curl -s https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/minimal_init.lua) && (echo "EOF")) ``` -------------------------------- ### Enable fzf-lua as UI for vim.ui.select Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua-opts.txt Register fzf-lua as the UI interface for vim.ui.select during setup. This allows fzf-lua to handle select prompts. ```lua require("fzf-lua").setup({ ui_select = true }) ``` -------------------------------- ### Configure Media File Previews in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Set up previewers for specific file extensions like 'png' and 'jpg' using external command-line tools. Configure 'ueberzug_scaler' for image scaling within the preview window. ```lua require("fzf-lua").setup({ previewers = { builtin = { extensions = { -- neovim terminal only supports `viu` block output ["png"] = { "viu", "-b" }, ["jpg"] = { "ueberzug" }, } -- When using 'ueberzug' we can also control the way images -- fill the preview area with ueberzug's image scaler, set to: -- false (no scaling), "crop", "distort", "fit_contain", -- "contain", "forced_cover", "cover" -- For more details see: -- https://github.com/seebye/ueberzug ueberzug_scaler = "cover", } }, }) ``` -------------------------------- ### Disable File Icons for Files Picker Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Disable the 'file_icons' option specifically for the 'files' picker using provider-specific setup options. ```lua require("fzf-lua").setup({ files = { file_icons = false } }) ``` -------------------------------- ### Use 'bat' as Previewer in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home To use 'bat' for syntax highlighting in the preview window, set 'winopts.preview.default' to 'bat' in your fzf-lua setup. ```lua require('fzf-lua').setup { winopts = { preview = { default = 'bat' } } } ``` -------------------------------- ### Configure fzf Binary Path Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Shows how to specify the path to the fzf binary using the `fzf_bin` global option if it's not in the system's PATH. ```lua require("fzf-lua").setup({ fzf_bin = "/usr/local/bin/fzf" }) ``` -------------------------------- ### Configure Preview Window Offset Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Demonstrates setting the preview window offset using the `preview_offset` global option, which is passed to fzf's `--preview-window` flag. ```lua require("fzf-lua").setup({ preview_offset = "right:50%" }) ``` -------------------------------- ### Glob Search for Specific Utilities Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Example of searching for the 'Partial' utility across both TypeScript and JavaScript files using glob patterns. ```sh Rg> Partial --*.ts* *.js ``` -------------------------------- ### Use Custom Flags in Grep Function Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Example of using custom flags with the `grep` function directly, similar to how `rg_glob_fn` would process them. ```lua :lua require("fzf-lua").grep({ no_esc=true, search="foo -- --word-regexp" }) ``` -------------------------------- ### Enable Cycling Through Results in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home To enable cycling through search results, set the '--cycle' option within the fzf_opts table in your fzf-lua setup. ```lua require('fzf-lua').setup { fzf_opts = { ['--cycle'] = true } } ``` -------------------------------- ### Combine Multiple FzfLua Profiles Source: https://github.com/ibhagwan/fzf-lua/blob/main/lua/fzf-lua/profiles/README.md Combine profiles by passing a table of profile names as the first argument to the setup function. This allows for modular configuration. ```lua require("fzf-lua").setup({ { "ivy", "hide" } }) ``` -------------------------------- ### Configure Man Page Previewer Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Sets the command to preview man pages. Adjust the flags based on your system (e.g., remove `-c` for man-db, use `man -P cat %s | col -bx` on OSX). ```lua man = { -- NOTE: remove the `-c` flag when using man-db -- replace with `man -P cat %s | col -bx` on OSX cmd = "man -c %s | col -bx", } ``` -------------------------------- ### Custom Git Status Icons Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Maps git status characters to custom icons and colors for display in fzf-lua. This example shows default mappings. ```lua icons = { ["M"] = { icon = "M", color = "yellow" }, ["D"] = { icon = "D", color = "red" }, ["A"] = { icon = "A", color = "green" }, ["R"] = { icon = "R", color = "yellow" }, ["C"] = { icon = "C", color = "yellow" }, ["T"] = { icon = "T", color = "magenta" }, ["?"] = { icon = "?", color = "magenta" }, } ``` -------------------------------- ### Configure Fzf Lua Colorschemes Live Preview Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Enable live preview for colorschemes and set window options for display. Use 'ignore_patterns' to exclude specific colorscheme names. ```lua colorschemes = { prompt = 'Colorschemes❯ ', live_preview = true, -- apply the colorscheme on preview? actions = { ["enter"] = actions.colorscheme }, winopts = { height = 0.55, width = 0.30, }, -- uncomment to ignore colorschemes names (lua patterns) -- ignore_patterns = { "^delek$", "^blue$" }, }, ``` -------------------------------- ### Disable File Icons Globally Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Disable the 'file_icons' option globally using provider defaults setup options. This affects interfaces like files and grep. ```lua require("fzf-lua").setup({ defaults = { file_icons = false } }) ``` -------------------------------- ### Configure Preview Window Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Set options for the fzf preview window, such as border style, line wrapping, vertical/horizontal layout, and title display. The `winopts` table allows for fine-grained control over the preview window's appearance and behavior. ```lua preview = { border = "rounded", -- preview border: accepts both `nvim_open_win` -- and fzf values (e.g. "border-top", "none") -- native fzf previewers (bat/cat/git/etc) -- can also be set to `fun(winopts, metadata)` wrap = false, -- preview line wrap (fzf's 'wrap|nowrap') hidden = false, -- start preview hidden vertical = "down:45%", -- up|down:size horizontal = "right:60%", -- right|left:size layout = "flex", -- horizontal|vertical|flex flip_columns = 100, -- #cols to switch to horizontal on flex -- Only used with the builtin previewer: title = true, -- preview border title (file/buf)? title_pos = "center", -- left|center|right, title alignment scrollbar = "float", -- `false` or string:'float|border' -- float: in-window floating border -- border: in-border "block" marker scrolloff = -1, -- float scrollbar offset from right -- applies only when scrollbar = 'float' delay = 20, -- delay(ms) displaying the preview -- prevents lag on fast scrolling winopts = { -- builtin previewer window options number = true, relativenumber = false, cursorline = true, cursorlineopt = "both", cursorcolumn = false, signcolumn = "no", list = false, foldenable = false, foldmethod = "manual", }, }, on_create = function() -- called once upon creation of the fzf main window -- can be used to add custom fzf-lua mappings, e.g: -- vim.keymap.set("t", "", "", { silent = true, buffer = true }) end, -- called once _after_ the fzf interface is closed -- on_close = function() ... end ``` -------------------------------- ### Call fzf Function with Automatic Colors Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Apply automatic fzf colorscheme generation for a specific fzf function call. This overrides global setup for that instance. ```lua :lua FzfLua.files({ fzf_colors = true }) ``` ```vim :FzfLua files fzf_colors=true ``` -------------------------------- ### Configuring Window Options for fzf_exec Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Customize the fzf window's appearance, like height and width, by passing `winopts` as an option to `fzf_exec`. ```lua :lua require'fzf-lua'.fzf_exec("ls", { winopts = { height=0.33, width=0.66 } }) ``` -------------------------------- ### Ignore file patterns for specific provider Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Configure `file_ignore_patterns` within a specific provider's settings in the `setup` function to apply ignore rules only to that provider. ```lua require'fzf-lua'.setup { files = { prompt = "Files> ", file_ignore_patterns = { "%.lua$", "%.vim$" }, } } ``` -------------------------------- ### Populate Preview Buffer with Custom Content Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Illustrates how to overwrite the 'populate_preview_buf' function to display custom content in the preview window. Also disables line numbering and word wrap. ```lua local fzf_lua = require("fzf-lua") local builtin = require("fzf-lua.previewer.builtin") -- Inherit from "base" instead of "buffer_or_file" local MyPreviewer = builtin.base:extend() function MyPreviewer:new(o, opts, fzf_win) MyPreviewer.super.new(self, o, opts, fzf_win) setmetatable(self, MyPreviewer) return self end function MyPreviewer:populate_preview_buf(entry_str) local tmpbuf = self:get_tmp_buffer() vim.api.nvim_buf_set_lines(tmpbuf, 0, -1, false, { string.format("SELECTED FILE: %s", entry_str) }) self:set_preview_buf(tmpbuf) self.win:update_preview_scrollbar() end -- Disable line numbering and word wrap function MyPreviewer:gen_winopts() local new_winopts = { wrap = false, number = false } return vim.tbl_extend("force", self.winopts, new_winopts) end fzf_lua.fzf_exec("rg --files", { previewer = MyPreviewer, prompt = "Select file> ", }) ``` -------------------------------- ### Customize fzf Files Command and Working Directory Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Shows how to use the `files` function with a custom prompt, command (`ls`), and working directory (`~/.config`). This allows for more specific file searching. ```lua :lua FzfLua.files({ prompt="LS> ", cmd = "ls", cwd="~/.config" }) ``` ```vim :FzfLua files prompt="LS> \" cmd=ls cwd=~/.config ``` -------------------------------- ### Lua table as contents for fzf_live Source: https://github.com/ibhagwan/fzf-lua/wiki/Advanced Example demonstrating how to use a Lua table as the return type for the `contents` function in `fzf_live` to populate fzf with a list of strings. ```APIDOC ## Lua table as contents for fzf_live ### Description This example shows how to return a Lua table from the `contents` function in `fzf_live`. Each element in the table represents a line to be displayed in the fzf interface. This is useful for generating lists of items dynamically. ### Method `fzf_live(contents, opts)` where `contents` returns a `table`. ### Parameters * `contents` (function): A function that takes a `query` string and returns a `table` of strings. * `opts` (table): Optional configuration table. `prompt` and `exec_empty_query` are demonstrated here. ### Request Example ```lua require 'fzf-lua'.fzf_live( function(args) local q = args[1] if not tonumber(q) then return { "Invalid number: " .. tostring(q) } end local lines = {} for i = 1, tonumber(q) do table.insert(lines, tostring(i)) end return lines end, { prompt = 'Live> ', exec_empty_query = true, } ) ``` ### Response N/A (modifies UI) #### Success Response (200) N/A (modifies UI) #### Response Example N/A (modifies UI) ``` -------------------------------- ### Set Global Floating Window Position Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Configure the global setup options to place the floating window at the bottom left corner. This setting applies to all fzf-lua interfaces. ```lua require("fzf-lua").setup({ winopts = { row = 1, col = 0 } }) ``` -------------------------------- ### Map Ctrl-q to Select All and Accept in fzf-lua Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Configure a keymap to send all selected items to the quickfix list using the `select-all+accept` action. This replicates Telescope's `ctrl-q` behavior. ```lua require('fzf-lua').setup({ keymap = { fzf = { true, -- Use to select all items and add them to the quickfix list ["ctrl-q"] = "select-all+accept", }, }, }) ``` -------------------------------- ### Globally ignore file patterns Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Set `file_ignore_patterns` in the global `setup` function to ignore specific file types across all providers. This uses Lua pattern matching. ```lua require'fzf-lua'.setup { -- ignore all '.lua' and '.vim' files file_ignore_patterns = { "%.lua$", "%.vim$" } } ``` -------------------------------- ### Set Preview Pager Command Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Shows how to specify a custom pager command for shell preview commands using the `preview_pager` global option, for example, using `delta`. ```lua require("fzf-lua").setup({ preview_pager = "delta" }) ``` -------------------------------- ### Configure Fzf Lua LSP Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Customize Language Server Protocol (LSP) integration in Fzf Lua. Options include prompt postfix, current working directory scope, async/timeout settings, file/git icons, and whether to jump directly to results. ```lua lsp = { prompt_postfix = '❯ ', -- will be appended to the LSP label -- to override use 'prompt' instead cwd_only = false, -- LSP/diagnostics for cwd only? async_or_timeout = 5000, -- timeout(ms) or 'true' for async calls file_icons = true, git_icons = false, jump1 = true, -- skip the UI when result is a single entry jump1_action = FzfLua.actions.file_edit -- The equivalent of using `includeDeclaration` in lsp buf calls, e.g: -- :lua vim.lsp.buf.references({includeDeclaration = false}) includeDeclaration = true, -- include current declaration in LSP context }, ``` -------------------------------- ### Configure fzf Command-Line Options Source: https://github.com/ibhagwan/fzf-lua/blob/main/OPTIONS.md Illustrates how to pass custom command-line options to the fzf binary using the `fzf_opts` global option, such as `--ansi` and `--border`. ```lua require("fzf-lua").setup({ fzf_opts = { ["--ansi"] = true, ["--border"] = "none", ["--height"] = "80%" } }) ``` -------------------------------- ### Send Custom Flags with Rg Glob Fn Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Example of using the custom `rg_glob_fn` to pass specific ripgrep flags, such as `--word-regexp`, along with glob patterns. ```sh *Rg> ^foo -- --word-regexp --glob="*.lua" ``` -------------------------------- ### Use Glob Separator in Live Grep Source: https://github.com/ibhagwan/fzf-lua/wiki/Home Example of using the glob separator to specify file patterns in live_grep. Anything after the separator is treated as a glob argument for ripgrep. ```sh *Rg> ^foo -- *.lua ``` -------------------------------- ### Awesome Colorschemes Actions Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Sets up actions for the 'awesome_colorschemes' picker, including applying a colorscheme on Enter, toggling background on Ctrl-G, updating on Ctrl-R, and deleting on Ctrl-X. Reload is enabled for update and delete actions. ```lua ["enter"] = actions.colorscheme, ["ctrl-g"] = { fn = actions.toggle_bg, exec_silent = true }, ["ctrl-r"] = { fn = actions.cs_update, reload = true }, ["ctrl-x"] = { fn = actions.cs_delete, reload = true }, ``` -------------------------------- ### Configure File Picker Defaults Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Sets global defaults for the file picker, such as enabling file icons and specifying how the quickfix list should open. The 'files' table contains options for the file picker. ```lua -- use `defaults` (table or function) if you wish to set "global-picker" defaults -- for example, using "mini.icons" globally and open the quickfix list at the top -- defaults = { -- file_icons = "mini", -- copen = "topleft copen", -- }, files = { -- previewer = "bat", -- uncomment to override previewer -- (name from 'previewers' table) -- set to 'false' to disable prompt = 'Files❯ ', multiprocess = true, -- run command in a separate process git_icons = false, -- show git icons? file_icons = true, -- show file icons (true|"devicons"|"mini")? color_icons = true, -- colorize file|git icons -- path_shorten = 1, -- 'true' or number, shorten path? -- Uncomment for custom vscode-like formatter where the filename is first: -- e.g. "fzf-lua/previewer/fzf.lua" => "fzf.lua previewer/fzf-lua" -- formatter = "path.filename_first", -- executed command priority is 'cmd' (if exists) -- otherwise auto-detect prioritizes `fd`:`rg`:`find` -- default options are controlled by 'fd|rg|find|_opts' } ``` -------------------------------- ### fzf-lua Command Execution with Arguments Source: https://github.com/ibhagwan/fzf-lua/blob/main/doc/fzf-lua.txt Shows how to pass arguments to fzf-lua commands, either through Lua or Vim commands. The example uses the `files` command with a `cwd` argument. ```lua :lua FzfLua.files({ cwd = '~/.config' }) -- or using the `FzfLua` vim command: :FzfLua files cwd=~/.config ``` -------------------------------- ### Custom fzf Colors Configuration Source: https://github.com/ibhagwan/fzf-lua/blob/main/README.md Define custom fzf colors using a table in the setup function. Supports mapping highlight groups and raw fzf color arguments. ```lua require('fzf-lua').setup { fzf_colors = { -- First existing highlight group will be used -- values in 3rd+ index will be passed raw -- i.e: `--color fg+:#010101:bold:underline` ["fg+"] = { "fg" , { "Comment", "Normal" }, "bold", "underline" }, -- It is also possible to pass raw values directly ["gutter"] = "-1" } } ```