-- -- Fuzzy finder configuration (files, grep, buffers, help) -- -- See https://github.com/ibhagwan/fzf-lua -- Avoid conflicts with the already existing fzf configuration at ~/.config/fzf/fzf.bash vim.env.FZF_DEFAULT_OPTS = nil local fzf = require("fzf-lua") -- Copy selected entries' paths to the clipboard (icon-stripped via entry_to_file). local function copy_to_clipboard(selected, opts) local entry_to_file = require("fzf-lua.path").entry_to_file vim.fn.setreg( "+", table.concat( vim.tbl_map(function(sel) return entry_to_file(sel, opts).path end, selected), "\n" ) ) end fzf.setup({ winopts = { preview = { layout = "flex", flip_columns = 120, }, }, keymap = { fzf = { true, -- inherit defaults ["tab"] = "down", -- navigate instead of fzf's default toggle ["btab"] = "up", ["ctrl-y"] = "toggle", -- multi-select toggle (tab no longer does it) }, builtin = { true, -- inherit defaults [""] = "toggle-preview", -- show/hide preview }, }, actions = { files = { true, ["alt-y"] = copy_to_clipboard }, -- files + live_grep buffers = { true, ["alt-y"] = copy_to_clipboard }, }, -- Sticky footer of keybinding hints, like --footer in ~/.config/fzf/fzf.bash. fzf_opts = { ["--footer"] = table.concat({ "Alt+Y\tcopy to clipboard", "Ctrl+Y\ttoggle selection", "Alt+/\tshow/hide preview", }, "\n"), }, }) vim.keymap.set("n", "ff", fzf.files, { desc = "Fuzzy-find files" }) vim.keymap.set("n", "fg", fzf.live_grep, { desc = "Fuzzy-find files content" }) vim.keymap.set("n", "fb", fzf.buffers, { desc = "Fuzzy-find buffers" }) vim.keymap.set("n", "fh", fzf.helptags, { desc = "Fuzzy-find help tags" }) vim.keymap.set("n", "fr", fzf.resume, { desc = "Resume last fuzzy-find picker" })