diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-13 00:26:25 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-13 00:39:24 +0200 |
| commit | 2b065376b0f43010ebd64f49552ab96377504079 (patch) | |
| tree | c1e56afc15055abcf558a7b995b40bd17af16543 /.config/nvim/plugin/50-fzf.lua | |
| parent | 99f4b2f13f07085ff5b131e4de2704f4d8ede62b (diff) | |
| download | dotfiles-2b065376b0f43010ebd64f49552ab96377504079.tar.gz dotfiles-2b065376b0f43010ebd64f49552ab96377504079.zip | |
refactor(nvim): rename files and move code around
Diffstat (limited to '.config/nvim/plugin/50-fzf.lua')
| -rw-r--r-- | .config/nvim/plugin/50-fzf.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.config/nvim/plugin/50-fzf.lua b/.config/nvim/plugin/50-fzf.lua new file mode 100644 index 0000000..e0c4ce3 --- /dev/null +++ b/.config/nvim/plugin/50-fzf.lua @@ -0,0 +1,64 @@ +-- +-- 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 + ["<M-/>"] = "toggle-preview", -- show/hide preview + ["<C-n>"] = "preview-half-page-down", -- scroll preview (Ctrl-j/k navigate) + ["<C-p>"] = "preview-half-page-up", + }, + }, + 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 copy to clipboard", + "Ctrl+Y toggle selection", + "Alt+/ show/hide preview", + }, "\n"), + }, +}) + +vim.keymap.set("n", "<Leader>ff", fzf.files, { desc = "Fuzzy-find files" }) +vim.keymap.set("n", "<Leader>fg", fzf.live_grep, { desc = "Fuzzy-find files content" }) +vim.keymap.set("n", "<Leader>fb", fzf.buffers, { desc = "Fuzzy-find buffers" }) +vim.keymap.set("n", "<Leader>fh", fzf.helptags, { desc = "Fuzzy-find help tags" }) +vim.keymap.set("n", "<Leader>fr", fzf.resume, { desc = "Resume last fuzzy-find picker" }) |
