summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-07 17:03:12 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-07 18:25:48 +0200
commitfe200fb84c97a23187f1843005d00c850861c625 (patch)
tree02636af74af955dceb944d1781a72cf5a8c29127
parent7cb95de38967a3d2dd403ede97213ae5b22d630d (diff)
downloaddotfiles-fe200fb84c97a23187f1843005d00c850861c625.tar.gz
dotfiles-fe200fb84c97a23187f1843005d00c850861c625.zip
misc(nvim): configure fzf to mirror ~/.config/fzf/fzf.bash
-rw-r--r--.config/nvim/plugin/50-fzf-lua.lua43
1 files changed, 43 insertions, 0 deletions
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, <F4>, 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,
+ ["<M-/>"] = "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", "<Leader>ff", fzf.files, { desc = "Fuzzy-find files" })