From aa62e1f27b0cb3d712d6f2b13071cca0f09379be Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 11 Sep 2025 16:38:11 +0100 Subject: Add a lot of changes --- home/.config/nvim/lua/custom/plugins/telescope.lua | 397 ++++++++++++++++----- 1 file changed, 305 insertions(+), 92 deletions(-) (limited to 'home/.config/nvim/lua/custom/plugins/telescope.lua') diff --git a/home/.config/nvim/lua/custom/plugins/telescope.lua b/home/.config/nvim/lua/custom/plugins/telescope.lua index d2e97d7..ed88754 100644 --- a/home/.config/nvim/lua/custom/plugins/telescope.lua +++ b/home/.config/nvim/lua/custom/plugins/telescope.lua @@ -1,129 +1,341 @@ -local map = require("mapper") - return { { "nvim-telescope/telescope.nvim", + branch = "master", + keys = { + { + "sg", + function() + require("telescope.builtin").live_grep() + end, + desc = "[S]earch by [G]rep", + }, + { + "sw", + function() + require("telescope.builtin").grep_string() + end, + desc = "[S]earch current [W]ord", + }, + { + "sf", + function() + require("telescope.builtin").find_files() + end, + desc = "[S]earch [F]iles", + }, + { + "", + function() + require("telescope.builtin").buffers() + end, + desc = "[ ] Find existing buffers", + }, + { + "/", + function() + require("telescope.builtin").current_buffer_fuzzy_find() + end, + desc = "[/] Fuzzily search in current buffer", + }, + { + "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", + }, + { + "st", + function() + require("telescope.builtin").treesitter() + end, + desc = "[S]earch [T]reesitter", + }, + { + "ss", + function() + require("telescope.builtin").builtin() + end, + desc = "[S]earch [S]elect Telescope", + }, + { + "sc", + function() + require("telescope.builtin").commands() + end, + desc = "[S]earch [C]ommands", + }, + { + "sh", + function() + require("telescope.builtin").help_tags() + end, + desc = "[S]earch [H]elp", + }, + { + "sm", + function() + require("telescope.builtin").man_pages() + end, + desc = "[S]earch [M]an pages", + }, + { + "sk", + function() + require("telescope.builtin").keymaps() + end, + desc = "[S]earch [K]eymaps", + }, + { + "sd", + function() + require("telescope.builtin").diagnostics() + end, + desc = "[S]earch [D]iagnostics", + }, + -- {"sr", function() require("telescope.builtin").resume() end, desc = '[S]earch [R]esume' }, + { + "s.", + function() + require("telescope.builtin").oldfiles() + end, + desc = '[S]earch Recent Files ("." for repeat)', + }, + { + "sq", + function() + require("telescope.builtin").quickfix() + end, + desc = "[S]earch [Q]uickfixlist", + }, + { + "sl", + function() + require("telescope.builtin").loclist() + end, + desc = "[S]earch [L]ocationlist", + }, + { + "sR", + function() + require("telescope.builtin").registers() + end, + desc = "[S]earch [R]egisters", + }, + { + "sa", + function() + require("telescope.builtin").autocommands() + end, + desc = "[S]earch [A]utocommands", + }, + + { + "gc", + function() + require("telescope.builtin").git_bcommits() + end, + desc = "[G]it buffer [C]commits", + }, + { + "gc", + function() + require("telescope.builtin").git_bcommits_range() + end, + desc = "[G]it [C]commits for selected range", + }, + { + "gC", + function() + require("telescope.builtin").git_commits() + end, + desc = "[G]it (all) [C]commits", + }, + { + "gb", + function() + require("telescope.builtin").git_branches() + end, + desc = "[G]it [B]ranches", + }, + { + "gs", + function() + require("telescope.builtin").git_status() + end, + desc = "[G]it [S]tatus", + }, + { + "gS", + function() + require("telescope.builtin").git_stash() + end, + desc = "[G]it [S]tash", + }, + { + "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 = { + [""] = actions_layout.toggle_preview, + ["d"] = actions.delete_buffer + actions.move_to_top, + ["a"] = actions.add_to_qflist, + ["s"] = actions.select_all, + }, i = { + ["jj"] = { "", type = "command" }, [""] = actions.move_selection_next, [""] = actions.move_selection_previous, + [""] = false, + [""] = actions_layout.toggle_preview, + [""] = actions.delete_buffer + actions.move_to_top, }, }, - 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" + }, + pickers = { + find_files = { + follow = true, + hidden = true, + find_command = { + "fd", + "--type", + "f", + "--color", + "never", }, - ["ui-select"] = { - require("telescope.themes").get_dropdown({ - -- even more opts - }), + }, + 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") - - local b = require("telescope.builtin") - - map.n("B", b.builtin) - map.n("/", b.live_grep) - map.n("?", b.grep_string) - map.n("f", function() - b.find_files({ - find_command = { - "fd", - "--type", - "file", - "--follow", - "--hidden", - "--exclude", - ".git", - }, - }) - end) - map.n("b", function() - b.buffers({ sort_lastused = true, initial_mode = "normal" }) - end) - - map.n("t", b.treesitter) - - map.n("c", b.commands) - map.n("h", b.help_tags) - map.n("m", b.man_pages) - map.n("k", b.keymaps) - map.n("Q", function() - b.quickfix({ initial_mode = "normal" }) - end) - map.n("L", function() - b.loclist({ initial_mode = "normal" }) - end) - map.n("R", function() - b.registers({ initial_mode = "normal" }) - end) - map.n("A", b.autocommands) - + require("telescope").load_extension("refactoring") vim.api.nvim_create_autocmd("LspAttach", { callback = function(event) - local bnmap = function(keys, func) - map.n(keys, func, { buffer = event.buf }) + 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", function() - b.lsp_definitions({ initial_mode = "normal" }) - end) + bnmap("gd", b.lsp_definitions, "[G]oto [D]efinition") bnmap("gvd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "vsplit" }) - end) + b.lsp_definitions({ jump_type = "vsplit" }) + end, "[G]oto in a [V]ertical split to [D]efinition") bnmap("gxd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "split" }) - end) + b.lsp_definitions({ jump_type = "split" }) + end, "[G]oto in a [X]horizontal split to [D]efinition") bnmap("gtd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "tab" }) - end) - bnmap("gi", function() - b.lsp_implementations({ initial_mode = "normal" }) - end) - bnmap("gvi", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "vsplit" }) - end) - bnmap("gxi", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "split" }) - end) - bnmap("gti", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "tab" }) - end) - bnmap("go", b.lsp_document_symbols) - bnmap("gS", b.lsp_dynamic_workspace_symbols) - bnmap("ge", function() - b.lsp_document_diagnostics({ initial_mode = "normal" }) - end) - bnmap("gE", function() - b.lsp_workspace_diagnostics({ initial_mode = "normal" }) - end) - bnmap("gr", function() - b.lsp_references({ initial_mode = "normal" }) - end) - bnmap("gic", function() - b.lsp_incoming_calls({ initial_mode = "normal" }) - end) - bnmap("goc", function() - b.lsp_outgoing_calls({ initial_mode = "normal" }) - end) + b.lsp_definitions({ jump_type = "tab" }) + end, "[G]oto in a [T]ab to [D]efinition") + bnmap("D", b.lsp_type_definitions, "Type [D]efinition") + bnmap("vD", function() + b.lsp_type_definitions({ jump_type = "vsplit" }) + end, "Open in a [V]ertical split Type [D]efinition") + bnmap("xD", function() + b.lsp_type_definitions({ jump_type = "split" }) + end, "Open in a [X]horizontal split Type [D]efinition") + bnmap("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("ic", b.lsp_incoming_calls, "[I]ncoming [C]alls") + bnmap("oc", b.lsp_outgoing_calls, "[O]utgoing [C]alls") + bnmap("gO", b.lsp_document_symbols, "d[O]ocument symbols") + bnmap( + "ws", + b.lsp_dynamic_workspace_symbols, + "[W]orkspace [S]ymbols" + ) end, }) end, @@ -134,6 +346,7 @@ return { build = "make", }, "nvim-telescope/telescope-ui-select.nvim", + "ThePrimeagen/refactoring.nvim", }, }, } -- cgit v1.2.3-70-g09d2