fix fzf
This commit is contained in:
@@ -1,116 +1,4 @@
|
|||||||
require('plugins.filetree')
|
require('plugins.filetree')
|
||||||
-- local finder = require('plugins.finder')
|
|
||||||
-- finder.setup({
|
|
||||||
-- exclude_patterns = { 'node_modules', 'dist', 'build', '.git', '.cache', '.turbo', '*-lock.json' },
|
|
||||||
-- use_disk_cache = true,
|
|
||||||
-- follow_symlinks = true,
|
|
||||||
-- })
|
|
||||||
|
|
||||||
local file_fd_opts = table.concat({
|
|
||||||
'--color=never',
|
|
||||||
'--type f',
|
|
||||||
'--type l',
|
|
||||||
'--hidden',
|
|
||||||
'--follow',
|
|
||||||
'--exclude .git',
|
|
||||||
'--exclude .cache',
|
|
||||||
'--exclude .turbo',
|
|
||||||
'--exclude node_modules',
|
|
||||||
'--exclude dist',
|
|
||||||
'--exclude build',
|
|
||||||
'--exclude "*-lock.json"',
|
|
||||||
'--exclude "*-lock.yaml"',
|
|
||||||
}, ' ')
|
|
||||||
|
|
||||||
local file_rg_opts = table.concat({
|
|
||||||
'--color=never',
|
|
||||||
'--files',
|
|
||||||
'--hidden',
|
|
||||||
'--follow',
|
|
||||||
'-g "!.git"',
|
|
||||||
'-g "!.cache"',
|
|
||||||
'-g "!.turbo"',
|
|
||||||
'-g "!node_modules"',
|
|
||||||
'-g "!dist"',
|
|
||||||
'-g "!build"',
|
|
||||||
'-g "!*-lock.json"',
|
|
||||||
'-g "!*-lock.yaml"',
|
|
||||||
}, ' ')
|
|
||||||
|
|
||||||
local function grep_rg_opts(extra)
|
|
||||||
local opts = {
|
|
||||||
'--column',
|
|
||||||
'--line-number',
|
|
||||||
'--no-heading',
|
|
||||||
'--color=always',
|
|
||||||
'--colors "path:none"',
|
|
||||||
'--colors "line:none"',
|
|
||||||
'--colors "column:none"',
|
|
||||||
'--colors "match:fg:166"',
|
|
||||||
'--colors "match:style:bold"',
|
|
||||||
'--smart-case',
|
|
||||||
'--max-columns=4096',
|
|
||||||
'--hidden',
|
|
||||||
'--follow',
|
|
||||||
'--glob "!.git"',
|
|
||||||
'--glob "!.cache"',
|
|
||||||
'--glob "!.turbo"',
|
|
||||||
'--glob "!node_modules"',
|
|
||||||
'--glob "!dist"',
|
|
||||||
'--glob "!build"',
|
|
||||||
'--glob "!*-lock.json"',
|
|
||||||
'--glob "!*-lock.yaml"',
|
|
||||||
}
|
|
||||||
|
|
||||||
vim.list_extend(opts, extra or {})
|
|
||||||
table.insert(opts, '-e')
|
|
||||||
|
|
||||||
return table.concat(opts, ' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
local function uniq_filter()
|
|
||||||
return [[awk '!seen[$0]++']]
|
|
||||||
end
|
|
||||||
|
|
||||||
local function files_cmd()
|
|
||||||
local fd = vim.fn.executable('fdfind') == 1 and 'fdfind' or vim.fn.executable('fd') == 1 and 'fd' or nil
|
|
||||||
if fd then
|
|
||||||
return table.concat({
|
|
||||||
'(',
|
|
||||||
fd .. ' ' .. file_fd_opts .. ' .;',
|
|
||||||
fd .. ' ' .. file_fd_opts .. ' --no-ignore --glob ".env*" .;',
|
|
||||||
'if [ -d _artifacts ]; then ' .. fd .. ' ' .. file_fd_opts .. ' --no-ignore . _artifacts; fi',
|
|
||||||
') | ' .. uniq_filter(),
|
|
||||||
}, ' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.executable('rg') == 1 then
|
|
||||||
return table.concat({
|
|
||||||
'(',
|
|
||||||
'rg ' .. file_rg_opts .. ' .;',
|
|
||||||
'rg ' .. file_rg_opts .. ' --no-ignore --glob ".env*" .;',
|
|
||||||
'if [ -d _artifacts ]; then rg ' .. file_rg_opts .. ' --no-ignore _artifacts; fi',
|
|
||||||
') | ' .. uniq_filter(),
|
|
||||||
}, ' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function grep_cmd(query)
|
|
||||||
local query_arg = query == '<query>' and query or vim.fn.shellescape(query or '')
|
|
||||||
local normal_rg = 'rg ' .. grep_rg_opts()
|
|
||||||
local ignored_rg = 'rg ' .. grep_rg_opts({ '--no-ignore' })
|
|
||||||
local env_rg = 'rg ' .. grep_rg_opts({ '--no-ignore', '--glob ".env*"' })
|
|
||||||
|
|
||||||
return table.concat({
|
|
||||||
'(',
|
|
||||||
normal_rg .. ' ' .. query_arg .. ' .;',
|
|
||||||
env_rg .. ' ' .. query_arg .. ' .;',
|
|
||||||
'if [ -d _artifacts ]; then ' .. ignored_rg .. ' ' .. query_arg .. ' _artifacts; fi',
|
|
||||||
') | ' .. uniq_filter(),
|
|
||||||
}, ' '), query
|
|
||||||
end
|
|
||||||
|
|
||||||
require('fzf-lua').setup({
|
require('fzf-lua').setup({
|
||||||
fzf_colors = {
|
fzf_colors = {
|
||||||
@@ -161,21 +49,8 @@ require('fzf-lua').setup({
|
|||||||
flip_columns = 120,
|
flip_columns = 120,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
files = {
|
|
||||||
cmd = files_cmd(),
|
|
||||||
fd_opts = file_fd_opts,
|
|
||||||
rg_opts = file_rg_opts,
|
|
||||||
},
|
|
||||||
grep = {
|
|
||||||
rg_opts = grep_rg_opts(),
|
|
||||||
fn_transform_cmd = grep_cmd,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
local fzf = require('fzf-lua')
|
local fzf = require('fzf-lua')
|
||||||
|
|
||||||
-- vim.keymap.set('n', '<leader>f', finder.files)
|
|
||||||
-- vim.keymap.set('n', '<leader>g', finder.grep)
|
|
||||||
-- vim.keymap.set('n', '<leader>fc', finder.clear_cache)
|
|
||||||
-- vim.keymap.set('n', '<leader>fD', finder.diagnose)
|
|
||||||
vim.keymap.set('n', '<leader>f', fzf.files)
|
vim.keymap.set('n', '<leader>f', fzf.files)
|
||||||
vim.keymap.set('n', '<leader>g', fzf.live_grep)
|
vim.keymap.set('n', '<leader>g', fzf.live_grep)
|
||||||
|
|||||||
Reference in New Issue
Block a user