return { -- Fuzzy finder. { "nvim-telescope/telescope.nvim", cmd = "Telescope", version = false, -- telescope did only one release, so use HEAD for now dependencies = { "nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-file-browser.nvim", }, keys = { { "", "Telescope file_browser", desc = "File browser" }, { "e", "Telescope find_files", desc = "Find file" }, { "b", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, { "f", "Telescope live_grep", desc = "Switch Buffer" }, { "h", "Telescope help_tags", desc = "Search help tags" }, { "z=", "Telescope spell_suggest", desc = "Spell options" }, }, opts = function() local actions = require("telescope.actions") local open_with_trouble = function(...) return require("trouble.providers.telescope").open_with_trouble(...) end local open_selected_with_trouble = function(...) return require("trouble.providers.telescope").open_selected_with_trouble(...) end return { defaults = { prompt_prefix = " ", selection_caret = " ", layout_config = { horizontal = { preview_width = 0.5 } }, file_ignore_patterns = { 'node_modules/.*' }, 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" } }, mappings = { i = { [""] = open_with_trouble, [""] = open_selected_with_trouble, [""] = actions.cycle_history_next, [""] = actions.cycle_history_prev, [""] = actions.preview_scrolling_down, [""] = actions.preview_scrolling_up, }, n = { ["q"] = actions.close, }, }, }, } end, }, -- add telescope-fzf-native { "telescope.nvim", dependencies = { "nvim-telescope/telescope-fzf-native.nvim", build = "gmake", config = function() require("telescope").load_extension("fzf") end, }, }, -- which-key helps you remember key bindings by showing a popup -- with the active keybindings of the command you started typing. { "folke/which-key.nvim", event = "VeryLazy", opts = { plugins = { spelling = true }, defaults = { mode = { "n", "v" }, ["g"] = { name = "+goto" }, ["gs"] = { name = "+surround" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, ["b"] = { name = "+buffer" }, ["c"] = { name = "+code" }, ["f"] = { name = "+file/find" }, ["g"] = { name = "+git" }, ["gh"] = { name = "+hunks" }, ["q"] = { name = "+quit/session" }, ["s"] = { name = "+search" }, ["u"] = { name = "+ui" }, ["w"] = { name = "+windows" }, ["x"] = { name = "+diagnostics/quickfix" }, }, }, config = function(_, opts) local wk = require("which-key") wk.setup(opts) wk.register(opts.defaults) end, }, -- git signs highlights text that has changed since the list -- git commit, and also lets you interactively stage & unstage -- hunks in a commit. { "lewis6991/gitsigns.nvim", opts = { signs = { add = { text = "▎" }, change = { text = "▎" }, delete = { text = "" }, topdelete = { text = "" }, changedelete = { text = "▎" }, untracked = { text = "▎" }, }, on_attach = function(buffer) local gs = package.loaded.gitsigns local function map(mode, l, r, desc) vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) end -- stylua: ignore start map("n", "]h", gs.next_hunk, "Next Hunk") map("n", "[h", gs.prev_hunk, "Prev Hunk") map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") map("n", "ghS", gs.stage_buffer, "Stage Buffer") map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") map("n", "ghR", gs.reset_buffer, "Reset Buffer") map("n", "ghp", gs.preview_hunk, "Preview Hunk") map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") map("n", "ghd", gs.diffthis, "Diff This") map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") end, }, }, -- Automatically highlights other instances of the word under your cursor. -- This works with LSP, Treesitter, and regexp matching to find the other -- instances. { "RRethy/vim-illuminate", opts = { delay = 200, large_file_cutoff = 2000, large_file_overrides = { providers = { "lsp" }, }, }, config = function(_, opts) require("illuminate").configure(opts) local function map(key, dir, buffer) vim.keymap.set("n", key, function() require("illuminate")["goto_" .. dir .. "_reference"](false) end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) end map("]]", "next") map("[[", "prev") -- also set it after loading ftplugins, since a lot overwrite [[ and ]] vim.api.nvim_create_autocmd("FileType", { callback = function() local buffer = vim.api.nvim_get_current_buf() map("]]", "next", buffer) map("[[", "prev", buffer) end, }) end, keys = { { "]]", desc = "Next Reference" }, { "[[", desc = "Prev Reference" }, }, }, -- buffer remove { "echasnovski/mini.bufremove", keys = { { "bd", function() local bd = require("mini.bufremove").delete if vim.bo.modified then local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel") if choice == 1 then -- Yes vim.cmd.write() bd(0) elseif choice == 2 then -- No bd(0, true) end else bd(0) end end, desc = "Delete Buffer", }, -- stylua: ignore { "bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, }, }, -- better diagnostics list and others { "folke/trouble.nvim", cmd = { "TroubleToggle", "Trouble" }, opts = { use_diagnostic_signs = true }, keys = { { "xx", "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, { "xX", "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, { "xL", "TroubleToggle loclist", desc = "Location List (Trouble)" }, { "xQ", "TroubleToggle quickfix", desc = "Quickfix List (Trouble)" }, { "[q", function() if require("trouble").is_open() then require("trouble").previous({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cprev) if not ok then vim.notify(err, vim.log.levels.ERROR) end end end, desc = "Previous trouble/quickfix item", }, { "]q", function() if require("trouble").is_open() then require("trouble").next({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cnext) if not ok then vim.notify(err, vim.log.levels.ERROR) end end end, desc = "Next trouble/quickfix item", }, }, }, -- Finds and lists all of the TODO, HACK, BUG, etc comment -- in your project and loads them into a browsable list. { "folke/todo-comments.nvim", cmd = { "TodoTrouble", "TodoTelescope" }, config = true, -- stylua: ignore keys = { { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, { "xt", "TodoTrouble", desc = "Todo (Trouble)" }, { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, { "st", "TodoTelescope", desc = "Todo" }, { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, }, }, }