From fe200fb84c97a23187f1843005d00c850861c625 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Sun, 7 Jun 2026 17:03:12 +0200 Subject: misc(nvim): configure fzf to mirror ~/.config/fzf/fzf.bash --- .config/nvim/plugin/50-fzf-lua.lua | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.config/nvim/plugin/50-fzf-lua.lua b/.config/nvim/plugin/50-fzf-lua.lua index 805bd20..e6d0402 100644 --- a/.config/nvim/plugin/50-fzf-lua.lua +++ b/.config/nvim/plugin/50-fzf-lua.lua @@ -8,6 +8,20 @@ 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 = { @@ -15,6 +29,35 @@ fzf.setup({ flip_columns = 120, }, }, + -- Mirror the shell fzf bindings from ~/.config/fzf/fzf.bash. Note: fzf-lua + -- uses a Neovim-rendered previewer, so preview moving/hiding lives in + -- `keymap.builtin`, not fzf's native `change-preview-window`. + -- The leading `true` inherits fzf-lua's defaults; without it these tables + -- replace the defaults outright (losing enter, ctrl-z, , etc.). + keymap = { + fzf = { + true, + ["tab"] = "down", -- navigate instead of fzf's default toggle + ["btab"] = "up", + ["ctrl-y"] = "toggle", -- multi-select toggle (tab no longer does it) + }, + builtin = { + true, + [""] = "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" }) -- cgit v1.3.1