1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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" })
|