Completely change from telescope to fzf, it's way more performant
This commit is contained in:
parent
3ecc70e179
commit
fc01aa096c
2 changed files with 39 additions and 98 deletions
|
|
@ -1,19 +1,47 @@
|
|||
return {
|
||||
"ibhagwan/fzf-lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {},
|
||||
opts = {
|
||||
"telescope",
|
||||
winopts = {
|
||||
preview = {
|
||||
default = "bat"
|
||||
}
|
||||
}
|
||||
},
|
||||
config = function()
|
||||
local fzf = require("fzf-lua")
|
||||
require("utils").add_keymaps({
|
||||
n = {
|
||||
["<leader>to"] = {
|
||||
cmd = function()
|
||||
fzf.files({
|
||||
git_icons = false,
|
||||
})
|
||||
end
|
||||
}
|
||||
local pickers = {
|
||||
{
|
||||
mapping = "o",
|
||||
action = function()
|
||||
fzf.files({
|
||||
git_icons = false,
|
||||
})
|
||||
end
|
||||
},
|
||||
{
|
||||
mapping = "a",
|
||||
action = function()
|
||||
fzf.live_grep_native({
|
||||
git_icons = false,
|
||||
rg_opts = "--hidden --column --line-number --no-heading --color=always --smart-case",
|
||||
fzf_opts = {
|
||||
['--exact'] = false, -- Disable exact matching
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
local keymaps = {}
|
||||
keymaps.n = {}
|
||||
for _, picker in ipairs(pickers) do
|
||||
keymaps.n["<leader>t" .. picker.mapping] = {
|
||||
cmd = picker.action
|
||||
}
|
||||
end
|
||||
|
||||
require("utils").add_keymaps(keymaps)
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build =
|
||||
"cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
|
||||
}
|
||||
},
|
||||
event = "VeryLazy",
|
||||
lazy = true,
|
||||
config = function()
|
||||
require("telescope").setup({
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require("telescope").load_extension("fzf")
|
||||
local dropdown = require("telescope.themes").get_dropdown({
|
||||
borderchars = {
|
||||
prompt = { "─", "│", "─", "│", "┌", "┐", "┘", "└" },
|
||||
results = { "─", "│", "─", "│", "├", "┤", "┘", "└" },
|
||||
preview = { "─", "│", "─", "│", "┌", "┐", "┘", "└" },
|
||||
},
|
||||
prompt_title = "",
|
||||
winblend = 20,
|
||||
width = 0.75
|
||||
})
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
local pickers = {
|
||||
-- {
|
||||
-- fn = builtin.find_files,
|
||||
-- key = "o",
|
||||
-- picker_opts = {
|
||||
-- prompt_prefix = "Files> ",
|
||||
-- previewer = false,
|
||||
-- },
|
||||
-- },
|
||||
{
|
||||
fn = builtin.current_buffer_fuzzy_find,
|
||||
key = "f",
|
||||
picker_opts = {
|
||||
prompt_prefix = "Find> "
|
||||
},
|
||||
},
|
||||
{
|
||||
fn = builtin.live_grep,
|
||||
key = "a",
|
||||
picker_opts = {
|
||||
prompt_prefix = "Grep> ",
|
||||
},
|
||||
},
|
||||
{
|
||||
fn = builtin.marks,
|
||||
key = "b",
|
||||
picker_opts = {
|
||||
prompt_prefix = "Marks> "
|
||||
},
|
||||
},
|
||||
}
|
||||
-- Cache the options with the dropdown theme for each picker so we don't
|
||||
-- recalculate it every time we open a picker
|
||||
local fzf_sorter = require("telescope.sorters").get_fzy_sorter()
|
||||
for _, v in ipairs(pickers) do
|
||||
-- Make sure all custom pickers are set to use the fzf sorter
|
||||
v.picker_opts.sorter = fzf_sorter
|
||||
v.picker_opts = vim.tbl_extend("force", dropdown, v.picker_opts)
|
||||
end
|
||||
|
||||
local keymaps = { n = {} }
|
||||
for _, v in ipairs(pickers) do
|
||||
keymaps.n["<leader>t" .. v.key] = {
|
||||
cmd = function()
|
||||
v.fn(v.picker_opts)
|
||||
end
|
||||
}
|
||||
end
|
||||
require("utils").add_keymaps(keymaps)
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue