diff options
| -rw-r--r-- | home/.config/nvim/lua/custom/plugins/telescope.lua | 694 |
1 files changed, 439 insertions, 255 deletions
diff --git a/home/.config/nvim/lua/custom/plugins/telescope.lua b/home/.config/nvim/lua/custom/plugins/telescope.lua index ed88754..1bae44e 100644 --- a/home/.config/nvim/lua/custom/plugins/telescope.lua +++ b/home/.config/nvim/lua/custom/plugins/telescope.lua @@ -1,352 +1,536 @@ return { { - "nvim-telescope/telescope.nvim", - branch = "master", + "ibhagwan/fzf-lua", + branch = "main", keys = { { - "<leader>sg", + "<localleader>b", function() - require("telescope.builtin").live_grep() + require("fzf-lua").buffers() end, - desc = "[S]earch by [G]rep", + desc = "fzf-lua by [G]rep", }, { - "<leader>sw", + "<localleader>g", function() - require("telescope.builtin").grep_string() + require("fzf-lua").live_grep() end, - desc = "[S]earch current [W]ord", + desc = "fzf-lua by [G]rep", }, { - "<leader>sf", + "<localleader>f", function() - require("telescope.builtin").find_files() + require("fzf-lua").files() end, - desc = "[S]earch [F]iles", + desc = "fzf-lua [F]iles", }, { "<leader><leader>", function() - require("telescope.builtin").buffers() + require("fzf-lua").global() end, - desc = "[ ] Find existing buffers", + desc = "fzf-lua global picker", }, { - "<leader>/", + "<localleader>d", function() - require("telescope.builtin").current_buffer_fuzzy_find() + require("fzf-lua").diagnostics() end, - desc = "[/] Fuzzily search in current buffer", + desc = "fzf-lua [D]iagnostics", }, { - "<leader>s/", + "<localleader>r", function() - require("telescope.builtin").live_grep({ - grep_open_files = true, - prompt_title = "Live Grep in Open Files", - }) + require("fzf-lua").resume() end, - desc = "[S]earch [/] in Open Files", + desc = "fzf-lua [R]esume", }, { - "<leader>st", + "<localleader>gc", function() - require("telescope.builtin").treesitter() - end, - desc = "[S]earch [T]reesitter", - }, - { - "<leader>ss", - function() - require("telescope.builtin").builtin() - end, - desc = "[S]earch [S]elect Telescope", - }, - { - "<leader>sc", - function() - require("telescope.builtin").commands() - end, - desc = "[S]earch [C]ommands", - }, - { - "<leader>sh", - function() - require("telescope.builtin").help_tags() - end, - desc = "[S]earch [H]elp", - }, - { - "<leader>sm", - function() - require("telescope.builtin").man_pages() - end, - desc = "[S]earch [M]an pages", - }, - { - "<leader>sk", - function() - require("telescope.builtin").keymaps() - end, - desc = "[S]earch [K]eymaps", - }, - { - "<leader>sd", - function() - require("telescope.builtin").diagnostics() - end, - desc = "[S]earch [D]iagnostics", - }, - -- {"<leader>sr", function() require("telescope.builtin").resume() end, desc = '[S]earch [R]esume' }, - { - "<leader>s.", - function() - require("telescope.builtin").oldfiles() - end, - desc = '[S]earch Recent Files ("." for repeat)', - }, - { - "<leader>sq", - function() - require("telescope.builtin").quickfix() - end, - desc = "[S]earch [Q]uickfixlist", - }, - { - "<leader>sl", - function() - require("telescope.builtin").loclist() - end, - desc = "[S]earch [L]ocationlist", - }, - { - "<leader>sR", - function() - require("telescope.builtin").registers() - end, - desc = "[S]earch [R]egisters", - }, - { - "<leader>sa", - function() - require("telescope.builtin").autocommands() - end, - desc = "[S]earch [A]utocommands", - }, - - { - "<leader>gc", - function() - require("telescope.builtin").git_bcommits() + require("fzf-lua").git_bcommits() end, desc = "[G]it buffer [C]commits", }, { - "<leader>gc", + "<localleader>gc", function() - require("telescope.builtin").git_bcommits_range() + require("fzf-lua").git_bcommits_range() end, desc = "[G]it [C]commits for selected range", }, { - "<leader>gC", + "<localleader>gC", function() - require("telescope.builtin").git_commits() + require("fzf-lua").git_commits() end, desc = "[G]it (all) [C]commits", }, { - "<leader>gb", + "<localleader>gb", function() - require("telescope.builtin").git_branches() + require("fzf-lua").git_branches() end, desc = "[G]it [B]ranches", }, { - "<leader>gs", + "<localleader>gs", function() - require("telescope.builtin").git_status() + require("fzf-lua").git_status() end, desc = "[G]it [S]tatus", }, { - "<leader>gS", + "<localleader>gS", function() - require("telescope.builtin").git_stash() + require("fzf-lua").git_stash() end, desc = "[G]it [S]tash", }, - { - "<leader>sr", - function() - require("telescope").extensions.refactoring.refactors() - end, - mode = { "n", "x" }, - desc = "[S]earch [R]efactor", - }, }, config = function() - local actions = require("telescope.actions") - local actions_layout = require("telescope.actions.layout") - require("telescope").setup({ - defaults = { - sorting_strategy = "ascending", - layout_config = { - prompt_position = "top", - height = 0.95, - width = 0.95, - flip_columns = 200, - vertical = { mirror = true }, - }, - layout_strategy = "flex", - preview = { - filesize_limit = 0.1, -- MB - }, - scroll_strategy = "cycle", - selection_strategy = "follow", - color_devicons = false, - mappings = { - n = { - ["<M-p>"] = actions_layout.toggle_preview, - ["d"] = actions.delete_buffer + actions.move_to_top, - ["a"] = actions.add_to_qflist, - ["s"] = actions.select_all, - }, - i = { - ["jj"] = { "<esc>", type = "command" }, - ["<c-j>"] = actions.move_selection_next, - ["<c-k>"] = actions.move_selection_previous, - ["<C-u>"] = false, - ["<M-p>"] = actions_layout.toggle_preview, - ["<c-d>"] = actions.delete_buffer + actions.move_to_top, - }, + local fzflua = require("fzf-lua") + fzflua.setup({ + keymap = { + builtin = { + true, + ["<M-p>"] = "toggle-preview", }, }, - pickers = { - find_files = { - follow = true, - hidden = true, - find_command = { - "fd", - "--type", - "f", - "--color", - "never", - }, - }, - live_grep = { - additional_args = { - "--hidden", - "--fixed-strings", - }, - }, - buffers = { - initial_mode = "normal", - sort_lastused = true, - }, - current_buffer_fuzzy_find = { - require("telescope.themes").get_dropdown({ - winblend = 10, - previewer = false, - }), - }, - quickfix = { - initial_mode = "normal", - }, - loclist = { - initial_mode = "normal", - }, - registers = { - initial_mode = "normal", - }, - lsp_definitions = { - initial_mode = "normal", - }, - lsp_type_definitions = { - initial_mode = "normal", - }, - lsp_implementations = { - initial_mode = "normal", - }, - lsp_references = { - initial_mode = "normal", - }, - lsp_incoming_calls = { - initial_mode = "normal", - }, - lsp_outgoing_calls = { - initial_mode = "normal", - }, + grep = { + hidden = true, + RIPGREP_CONFIG_PATH = "~/.config/ripgrep/ripgreprc", }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" + lsp = { + includeDeclaration = false, + }, + actions = { + files = { + true, + ["ctrl-x"] = FzfLua.actions.file_split, }, }, }) - require("telescope").load_extension("fzf") - require("telescope").load_extension("ui-select") - require("telescope").load_extension("refactoring") - vim.api.nvim_create_autocmd("LspAttach", { callback = function(event) - local b = require("telescope.builtin") local bnmap = function(keys, func, desc) - vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + vim.keymap.set( + "n", + keys, + func, + { buffer = event.buf, desc = "LSP: " .. desc } + ) end - bnmap("gd", b.lsp_definitions, "[G]oto [D]efinition") + bnmap("gd", fzflua.lsp_definitions, "[G]oto [D]efinition") bnmap("gvd", function() - b.lsp_definitions({ jump_type = "vsplit" }) + fzflua.lsp_definitions({ jump1_action = fzflua.actions.file_vsplit }) end, "[G]oto in a [V]ertical split to [D]efinition") bnmap("gxd", function() - b.lsp_definitions({ jump_type = "split" }) + fzflua.lsp_definitions({ jump1_action = fzflua.actions.file_split }) end, "[G]oto in a [X]horizontal split to [D]efinition") bnmap("gtd", function() - b.lsp_definitions({ jump_type = "tab" }) + fzflua.lsp_definitions({ + jump1_action = fzflua.actions.file_tabedit, + }) end, "[G]oto in a [T]ab to [D]efinition") - bnmap("<leader>D", b.lsp_type_definitions, "Type [D]efinition") + bnmap("<leader>D", fzflua.lsp_typedefs, "Type [D]efinition") bnmap("<leader>vD", function() - b.lsp_type_definitions({ jump_type = "vsplit" }) + fzflua.lsp_typedefs({ jump1_action = fzflua.actions.file_vsplit }) end, "Open in a [V]ertical split Type [D]efinition") bnmap("<leader>xD", function() - b.lsp_type_definitions({ jump_type = "split" }) + fzflua.lsp_typedefs({ jump1_action = fzflua.actions.file_split }) end, "Open in a [X]horizontal split Type [D]efinition") bnmap("<leader>tD", function() - b.lsp_type_definitions({ jump_type = "tab" }) + fzflua.lsp_typedefs({ jump1_action = fzflua.actions.file_tabedit }) end, "Open in a [T]ab Type [D]efinition") - bnmap("gri", b.lsp_implementations, "[G]oto [I]mplementation") + bnmap("gri", fzflua.lsp_implementations, "[G]oto [I]mplementation") bnmap("grvi", function() - b.lsp_implementations({ jump_type = "vsplit" }) + fzflua.lsp_implementations({ + jump1_action = fzflua.actions.file_vsplit, + }) end, "[G]oto in a [V]ertical split to [I]mplementation") bnmap("grxi", function() - b.lsp_implementations({ jump_type = "split" }) + fzflua.lsp_implementations({ + jump1_action = fzflua.actions.file_split, + }) end, "[G]oto in a [X]horizontal split to [I]mplementation") bnmap("grti", function() - b.lsp_implementations({ jump_type = "tab" }) + fzflua.lsp_implementations({ + jump1_action = fzflua.actions.file_tabedit, + }) end, "[G]oto in a [T]ab to [I]mplementation") - bnmap("grr", b.lsp_references, "[G]oto [R]eferences") - bnmap("<leader>ic", b.lsp_incoming_calls, "[I]ncoming [C]alls") - bnmap("<leader>oc", b.lsp_outgoing_calls, "[O]utgoing [C]alls") - bnmap("gO", b.lsp_document_symbols, "d[O]ocument symbols") + bnmap("grr", fzflua.lsp_references, "[G]oto [R]eferences") + bnmap("<leader>ic", fzflua.lsp_incoming_calls, "[I]ncoming [C]alls") + bnmap("<leader>oc", fzflua.lsp_outgoing_calls, "[O]utgoing [C]alls") + bnmap("gO", fzflua.lsp_document_symbols, "d[O]ocument symbols") bnmap( "<leader>ws", - b.lsp_dynamic_workspace_symbols, + fzflua.lsp_live_workspace_symbols, "[W]orkspace [S]ymbols" ) + bnmap( + "<leader>wd", + fzflua.diagnostics_workspace, + "[W]orkspace [D]iagnostics" + ) end, }) + fzflua.register_ui_select() end, - dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - }, - "nvim-telescope/telescope-ui-select.nvim", - "ThePrimeagen/refactoring.nvim", - }, }, + -- { + -- "nvim-telescope/telescope.nvim", + -- branch = "master", + -- keys = { + -- { + -- "<leader>sg", + -- function() + -- require("telescope.builtin").live_grep() + -- end, + -- desc = "[S]earch by [G]rep", + -- }, + -- { + -- "<leader>sw", + -- function() + -- require("telescope.builtin").grep_string() + -- end, + -- desc = "[S]earch current [W]ord", + -- }, + -- { + -- "<leader>sf", + -- function() + -- require("telescope.builtin").find_files() + -- end, + -- desc = "[S]earch [F]iles", + -- }, + -- { + -- "<leader><leader>", + -- function() + -- require("telescope.builtin").buffers() + -- end, + -- desc = "[ ] Find existing buffers", + -- }, + -- { + -- "<leader>/", + -- function() + -- require("telescope.builtin").current_buffer_fuzzy_find() + -- end, + -- desc = "[/] Fuzzily search in current buffer", + -- }, + -- { + -- "<leader>s/", + -- function() + -- require("telescope.builtin").live_grep({ + -- grep_open_files = true, + -- prompt_title = "Live Grep in Open Files", + -- }) + -- end, + -- desc = "[S]earch [/] in Open Files", + -- }, + -- { + -- "<leader>st", + -- function() + -- require("telescope.builtin").treesitter() + -- end, + -- desc = "[S]earch [T]reesitter", + -- }, + -- { + -- "<leader>ss", + -- function() + -- require("telescope.builtin").builtin() + -- end, + -- desc = "[S]earch [S]elect Telescope", + -- }, + -- { + -- "<leader>sc", + -- function() + -- require("telescope.builtin").commands() + -- end, + -- desc = "[S]earch [C]ommands", + -- }, + -- { + -- "<leader>sh", + -- function() + -- require("telescope.builtin").help_tags() + -- end, + -- desc = "[S]earch [H]elp", + -- }, + -- { + -- "<leader>sm", + -- function() + -- require("telescope.builtin").man_pages() + -- end, + -- desc = "[S]earch [M]an pages", + -- }, + -- { + -- "<leader>sk", + -- function() + -- require("telescope.builtin").keymaps() + -- end, + -- desc = "[S]earch [K]eymaps", + -- }, + -- { + -- "<leader>sd", + -- function() + -- require("telescope.builtin").diagnostics() + -- end, + -- desc = "[S]earch [D]iagnostics", + -- }, + -- -- {"<leader>sr", function() require("telescope.builtin").resume() end, desc = '[S]earch [R]esume' }, + -- { + -- "<leader>s.", + -- function() + -- require("telescope.builtin").oldfiles() + -- end, + -- desc = '[S]earch Recent Files ("." for repeat)', + -- }, + -- { + -- "<leader>sq", + -- function() + -- require("telescope.builtin").quickfix() + -- end, + -- desc = "[S]earch [Q]uickfixlist", + -- }, + -- { + -- "<leader>sl", + -- function() + -- require("telescope.builtin").loclist() + -- end, + -- desc = "[S]earch [L]ocationlist", + -- }, + -- { + -- "<leader>sR", + -- function() + -- require("telescope.builtin").registers() + -- end, + -- desc = "[S]earch [R]egisters", + -- }, + -- { + -- "<leader>sa", + -- function() + -- require("telescope.builtin").autocommands() + -- end, + -- desc = "[S]earch [A]utocommands", + -- }, + -- + -- { + -- "<leader>gc", + -- function() + -- require("telescope.builtin").git_bcommits() + -- end, + -- desc = "[G]it buffer [C]commits", + -- }, + -- { + -- "<leader>gc", + -- function() + -- require("telescope.builtin").git_bcommits_range() + -- end, + -- desc = "[G]it [C]commits for selected range", + -- }, + -- { + -- "<leader>gC", + -- function() + -- require("telescope.builtin").git_commits() + -- end, + -- desc = "[G]it (all) [C]commits", + -- }, + -- { + -- "<leader>gb", + -- function() + -- require("telescope.builtin").git_branches() + -- end, + -- desc = "[G]it [B]ranches", + -- }, + -- { + -- "<leader>gs", + -- function() + -- require("telescope.builtin").git_status() + -- end, + -- desc = "[G]it [S]tatus", + -- }, + -- { + -- "<leader>gS", + -- function() + -- require("telescope.builtin").git_stash() + -- end, + -- desc = "[G]it [S]tash", + -- }, + -- { + -- "<leader>sr", + -- function() + -- require("telescope").extensions.refactoring.refactors() + -- end, + -- mode = { "n", "x" }, + -- desc = "[S]earch [R]efactor", + -- }, + -- }, + -- config = function() + -- local actions = require("telescope.actions") + -- local actions_layout = require("telescope.actions.layout") + -- require("telescope").setup({ + -- defaults = { + -- sorting_strategy = "ascending", + -- layout_config = { + -- prompt_position = "top", + -- height = 0.95, + -- width = 0.95, + -- flip_columns = 200, + -- vertical = { mirror = true }, + -- }, + -- layout_strategy = "flex", + -- preview = { + -- filesize_limit = 0.1, -- MB + -- }, + -- scroll_strategy = "cycle", + -- selection_strategy = "follow", + -- color_devicons = false, + -- mappings = { + -- n = { + -- ["<M-p>"] = actions_layout.toggle_preview, + -- ["d"] = actions.delete_buffer + actions.move_to_top, + -- ["a"] = actions.add_to_qflist, + -- ["s"] = actions.select_all, + -- }, + -- i = { + -- ["jj"] = { "<esc>", type = "command" }, + -- ["<c-j>"] = actions.move_selection_next, + -- ["<c-k>"] = actions.move_selection_previous, + -- ["<C-u>"] = false, + -- ["<M-p>"] = actions_layout.toggle_preview, + -- ["<c-d>"] = actions.delete_buffer + actions.move_to_top, + -- }, + -- }, + -- }, + -- pickers = { + -- find_files = { + -- follow = true, + -- hidden = true, + -- find_command = { + -- "fd", + -- "--type", + -- "f", + -- "--color", + -- "never", + -- }, + -- }, + -- live_grep = { + -- additional_args = { + -- "--hidden", + -- "--fixed-strings", + -- }, + -- }, + -- buffers = { + -- initial_mode = "normal", + -- sort_lastused = true, + -- }, + -- current_buffer_fuzzy_find = { + -- require("telescope.themes").get_dropdown({ + -- winblend = 10, + -- previewer = false, + -- }), + -- }, + -- quickfix = { + -- initial_mode = "normal", + -- }, + -- loclist = { + -- initial_mode = "normal", + -- }, + -- registers = { + -- initial_mode = "normal", + -- }, + -- lsp_definitions = { + -- initial_mode = "normal", + -- }, + -- lsp_type_definitions = { + -- initial_mode = "normal", + -- }, + -- lsp_implementations = { + -- initial_mode = "normal", + -- }, + -- lsp_references = { + -- initial_mode = "normal", + -- }, + -- lsp_incoming_calls = { + -- initial_mode = "normal", + -- }, + -- lsp_outgoing_calls = { + -- initial_mode = "normal", + -- }, + -- }, + -- extensions = { + -- fzf = { + -- fuzzy = true, -- false will only do exact matching + -- override_generic_sorter = true, -- override the generic sorter + -- override_file_sorter = true, -- override the file sorter + -- case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- }, + -- }, + -- }) + -- require("telescope").load_extension("fzf") + -- require("telescope").load_extension("ui-select") + -- require("telescope").load_extension("refactoring") + -- + -- vim.api.nvim_create_autocmd("LspAttach", { + -- callback = function(event) + -- local b = require("telescope.builtin") + -- local bnmap = function(keys, func, desc) + -- vim.keymap.set( + -- "n", + -- keys, + -- func, + -- { buffer = event.buf, desc = "LSP: " .. desc } + -- ) + -- end + -- bnmap("gd", b.lsp_definitions, "[G]oto [D]efinition") + -- bnmap("gvd", function() + -- b.lsp_definitions({ jump_type = "vsplit" }) + -- end, "[G]oto in a [V]ertical split to [D]efinition") + -- bnmap("gxd", function() + -- b.lsp_definitions({ jump_type = "split" }) + -- end, "[G]oto in a [X]horizontal split to [D]efinition") + -- bnmap("gtd", function() + -- b.lsp_definitions({ jump_type = "tab" }) + -- end, "[G]oto in a [T]ab to [D]efinition") + -- bnmap("<leader>D", b.lsp_type_definitions, "Type [D]efinition") + -- bnmap("<leader>vD", function() + -- b.lsp_type_definitions({ jump_type = "vsplit" }) + -- end, "Open in a [V]ertical split Type [D]efinition") + -- bnmap("<leader>xD", function() + -- b.lsp_type_definitions({ jump_type = "split" }) + -- end, "Open in a [X]horizontal split Type [D]efinition") + -- bnmap("<leader>tD", function() + -- b.lsp_type_definitions({ jump_type = "tab" }) + -- end, "Open in a [T]ab Type [D]efinition") + -- bnmap("gri", b.lsp_implementations, "[G]oto [I]mplementation") + -- bnmap("grvi", function() + -- b.lsp_implementations({ jump_type = "vsplit" }) + -- end, "[G]oto in a [V]ertical split to [I]mplementation") + -- bnmap("grxi", function() + -- b.lsp_implementations({ jump_type = "split" }) + -- end, "[G]oto in a [X]horizontal split to [I]mplementation") + -- bnmap("grti", function() + -- b.lsp_implementations({ jump_type = "tab" }) + -- end, "[G]oto in a [T]ab to [I]mplementation") + -- bnmap("grr", b.lsp_references, "[G]oto [R]eferences") + -- bnmap("<leader>ic", b.lsp_incoming_calls, "[I]ncoming [C]alls") + -- bnmap("<leader>oc", b.lsp_outgoing_calls, "[O]utgoing [C]alls") + -- bnmap("gO", b.lsp_document_symbols, "d[O]ocument symbols") + -- bnmap( + -- "<leader>ws", + -- b.lsp_dynamic_workspace_symbols, + -- "[W]orkspace [S]ymbols" + -- ) + -- end, + -- }) + -- end, + -- dependencies = { + -- "nvim-lua/plenary.nvim", + -- { + -- "nvim-telescope/telescope-fzf-native.nvim", + -- build = "make", + -- }, + -- "nvim-telescope/telescope-ui-select.nvim", + -- "ThePrimeagen/refactoring.nvim", + -- }, + -- }, } |
