From fc01aa096c27f0d4fca6b01fd5ff7309ace7d05c Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Mon, 16 Sep 2024 00:12:30 +0200 Subject: [PATCH] Completely change from telescope to fzf, it's way more performant --- home/.config/nvim/lua/plugs/fzf.lua | 50 ++++++++++--- home/.config/nvim/lua/plugs/telescope.lua | 87 ----------------------- 2 files changed, 39 insertions(+), 98 deletions(-) delete mode 100644 home/.config/nvim/lua/plugs/telescope.lua diff --git a/home/.config/nvim/lua/plugs/fzf.lua b/home/.config/nvim/lua/plugs/fzf.lua index 198f305..c018afd 100644 --- a/home/.config/nvim/lua/plugs/fzf.lua +++ b/home/.config/nvim/lua/plugs/fzf.lua @@ -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 = { - ["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["t" .. picker.mapping] = { + cmd = picker.action + } + end + + require("utils").add_keymaps(keymaps) end } diff --git a/home/.config/nvim/lua/plugs/telescope.lua b/home/.config/nvim/lua/plugs/telescope.lua deleted file mode 100644 index 720b4f8..0000000 --- a/home/.config/nvim/lua/plugs/telescope.lua +++ /dev/null @@ -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["t" .. v.key] = { - cmd = function() - v.fn(v.picker_opts) - end - } - end - require("utils").add_keymaps(keymaps) - end, -}