271 lines
11 KiB
Lua
271 lines
11 KiB
Lua
|
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 = {
|
||
|
{ "<C-n>", "<cmd>Telescope file_browser<cr>", desc = "File browser" },
|
||
|
{ "<leader>e", "<cmd>Telescope find_files<cr>", desc = "Find file" },
|
||
|
{ "<leader>b", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
|
||
|
{ "<leader>f", "<cmd>Telescope live_grep<cr>", desc = "Switch Buffer" },
|
||
|
{ "<leader>h", "<cmd>Telescope help_tags<cr>", desc = "Search help tags" },
|
||
|
{ "z=", "<cmd>Telescope spell_suggest<cr>", 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 = {
|
||
|
["<c-t>"] = open_with_trouble,
|
||
|
["<a-t>"] = open_selected_with_trouble,
|
||
|
["<C-Down>"] = actions.cycle_history_next,
|
||
|
["<C-Up>"] = actions.cycle_history_prev,
|
||
|
["<C-f>"] = actions.preview_scrolling_down,
|
||
|
["<C-b>"] = 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" },
|
||
|
["<leader><tab>"] = { name = "+tabs" },
|
||
|
["<leader>b"] = { name = "+buffer" },
|
||
|
["<leader>c"] = { name = "+code" },
|
||
|
["<leader>f"] = { name = "+file/find" },
|
||
|
["<leader>g"] = { name = "+git" },
|
||
|
["<leader>gh"] = { name = "+hunks" },
|
||
|
["<leader>q"] = { name = "+quit/session" },
|
||
|
["<leader>s"] = { name = "+search" },
|
||
|
["<leader>u"] = { name = "+ui" },
|
||
|
["<leader>w"] = { name = "+windows" },
|
||
|
["<leader>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" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
|
||
|
map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
|
||
|
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
|
||
|
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
|
||
|
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
|
||
|
map("n", "<leader>ghp", gs.preview_hunk, "Preview Hunk")
|
||
|
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
|
||
|
map("n", "<leader>ghd", gs.diffthis, "Diff This")
|
||
|
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
|
||
|
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "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 = {
|
||
|
{
|
||
|
"<leader>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
|
||
|
{ "<leader>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 = {
|
||
|
{ "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
|
||
|
{ "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
|
||
|
{ "<leader>xL", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
|
||
|
{ "<leader>xQ", "<cmd>TroubleToggle quickfix<cr>", 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" },
|
||
|
{ "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
|
||
|
{ "<leader>xT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
|
||
|
{ "<leader>st", "<cmd>TodoTelescope<cr>", desc = "Todo" },
|
||
|
{ "<leader>sT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme" },
|
||
|
},
|
||
|
},
|
||
|
}
|