mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(Neovim): Sensible keymaps, prune plugins, Kickstart.nvim LSP code
This commit is contained in:
@@ -15,10 +15,10 @@ return {
|
||||
-- Build Step is needed for regex support in snippets.
|
||||
-- This step is not supported in many windows environments.
|
||||
-- Remove the below condition to re-enable on windows.
|
||||
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
|
||||
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
|
||||
return
|
||||
end
|
||||
return 'make install_jsregexp'
|
||||
return "make install_jsregexp"
|
||||
end)(),
|
||||
dependencies = {
|
||||
-- `friendly-snippets` contains a variety of premade snippets.
|
||||
@@ -27,7 +27,7 @@ return {
|
||||
{
|
||||
"rafamadriz/friendly-snippets",
|
||||
config = function()
|
||||
require('luasnip.loaders.from_vscode')
|
||||
require("luasnip.loaders.from_vscode")
|
||||
end,
|
||||
},
|
||||
},
|
||||
@@ -90,12 +90,12 @@ return {
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
end, { "i", "s" }),
|
||||
["<C-h>"] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
|
||||
@@ -34,10 +34,10 @@ return {
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>qq", desc = "Query UI" },
|
||||
{ "<leader>qq", "<cmd>DBUIToggle<cr>", desc = "Query UI Toggle" },
|
||||
{ "<leader>qa", "<cmd>DBUIAddConnection<cr>", desc = "Query: Add Connection" },
|
||||
{ "<leader>qf", "<cmd>DBUIFindBuffer<cr>", desc = "Query: Find Connection" },
|
||||
{ "<leader>qq", desc = "DB: UI" },
|
||||
{ "<leader>qq", "<cmd>DBUIToggle<cr>", desc = "DB: UI Toggle" },
|
||||
{ "<leader>qa", "<cmd>DBUIAddConnection<cr>", desc = "DB: Add Connection" },
|
||||
{ "<leader>qf", "<cmd>DBUIFindBuffer<cr>", desc = "DB: Find Connection" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,77 +1 @@
|
||||
-- Primarily focused on configuring the debugger for Go, but can
|
||||
-- be extended to other languages as well.
|
||||
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
dependencies = {
|
||||
-- Creates a beautiful debugger UI
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-neotest/nvim-nio",
|
||||
|
||||
-- Installs the debug adapters for you
|
||||
"williamboman/mason.nvim",
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
|
||||
-- Add your own debuggers here
|
||||
"leoluz/nvim-dap-go",
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
|
||||
require("mason-nvim-dap").setup({
|
||||
-- Makes a best effort to setup the various debuggers with reasonable debug configurations
|
||||
automatic_setup = true,
|
||||
|
||||
-- see mason-nvim-dap README for more information
|
||||
handlers = {},
|
||||
|
||||
-- You'll need to check that you have the required things installed online
|
||||
ensure_installed = {
|
||||
-- Update this to ensure that you have the debuggers for the langs you want
|
||||
-- "delve",
|
||||
-- TODO: Rust, C#, TS/JS, Python
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" })
|
||||
vim.keymap.set("n", "<F11>", dap.step_into, { desc = "Debug: Step Into" })
|
||||
vim.keymap.set("n", "<S-F11>", dap.step_over, { desc = "Debug: Step Over" })
|
||||
vim.keymap.set("n", "<F12>", dap.step_out, { desc = "Debug: Step Out" })
|
||||
vim.keymap.set("n", "<F9>", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" })
|
||||
vim.keymap.set("n", "<S-F9>", function()
|
||||
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end, { desc = "Debug: Set Breakpoint" })
|
||||
|
||||
-- For more information, see |:help nvim-dap-ui|
|
||||
dapui.setup({
|
||||
-- Set icons to characters that are more likely to work in every terminal.
|
||||
icons = { expanded = "▾", collapsed = "▸", current_frame = "*" },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = "⏸",
|
||||
play = "▶",
|
||||
step_into = "⏎",
|
||||
step_over = "⏭",
|
||||
step_out = "⏮",
|
||||
step_back = "b",
|
||||
run_last = "▶▶",
|
||||
terminate = "⏹",
|
||||
disconnect = "⏏",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
|
||||
vim.keymap.set("n", "<F7>", dapui.toggle, { desc = "Debug: See last session result." })
|
||||
|
||||
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
|
||||
dap.listeners.before.event_terminated["dapui_config"] = dapui.close
|
||||
dap.listeners.before.event_exited["dapui_config"] = dapui.close
|
||||
|
||||
-- Install golang specific config
|
||||
-- require("dap-go").setup()
|
||||
-- TODO: Rust, C#, TS/JS, Python
|
||||
end,
|
||||
}
|
||||
return {}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
return {
|
||||
|
||||
-- TODO:
|
||||
-- Reduce noice timeout
|
||||
{ "tpope/vim-repeat" },
|
||||
|
||||
-- Better code folding
|
||||
@@ -16,8 +19,8 @@ return {
|
||||
require("statuscol").setup({
|
||||
relculright = true,
|
||||
segments = {
|
||||
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||
{ text = { builtin.foldfunc }, click = "v:lua.ScFa" },
|
||||
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||
{ text = { builtin.foldfunc }, click = "v:lua.ScFa" },
|
||||
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||
},
|
||||
})
|
||||
@@ -110,34 +113,6 @@ return {
|
||||
main = "ibl",
|
||||
},
|
||||
|
||||
-- Collection of various small independent plugins/modules
|
||||
{
|
||||
"chasnovski/mini.nvim",
|
||||
config = function()
|
||||
-- Better Around/Inside textobjects
|
||||
--
|
||||
-- Examples:
|
||||
-- - va) - [V]isually select [A]round [)]paren
|
||||
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
|
||||
-- - ci' - [C]hange [I]nside [']quote
|
||||
require('mini.ai').setup { n_lines = 500 }
|
||||
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
--
|
||||
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
||||
-- - sd' - [S]urround [D]elete [']quotes
|
||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||
require('mini.surround').setup()
|
||||
|
||||
require("mini.pairs").setup()
|
||||
require("mini.comment").setup()
|
||||
require("mini.completion").setup()
|
||||
|
||||
-- ... and there is more!
|
||||
-- Check out: https://github.com/echasnovski/mini.nvim
|
||||
end,
|
||||
},
|
||||
|
||||
-- Highlights the current level of indentation, and animates the highlighting.
|
||||
{
|
||||
"echasnovski/mini.indentscope",
|
||||
@@ -162,6 +137,72 @@ return {
|
||||
end,
|
||||
},
|
||||
|
||||
-- mini.nvim: Collection of various small independent plugins/modules
|
||||
{
|
||||
"echasnovski/mini.nvim",
|
||||
version = false,
|
||||
config = function()
|
||||
-- Better Around/Inside textobjects
|
||||
--
|
||||
-- - va) - [V]isually select [A]round [)]paren
|
||||
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
|
||||
-- - ci' - [C]hange [I]nside [']quote
|
||||
require("mini.ai").setup({ n_lines = 500 })
|
||||
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
--
|
||||
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
||||
-- - sd' - [S]urround [D]elete [']quotes
|
||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||
require("mini.surround").setup()
|
||||
|
||||
-- gc
|
||||
require("mini.comment").setup()
|
||||
|
||||
require("mini.pairs").setup()
|
||||
require("mini.completion").setup()
|
||||
end,
|
||||
},
|
||||
|
||||
-- Automatically highlights other instances of the word under cursor
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
lazy = false,
|
||||
opts = {
|
||||
delay = 200,
|
||||
large_file_cutoff = 2000,
|
||||
large_file_override = {
|
||||
providers = { "lsp" },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- Copied from LazyNvim
|
||||
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" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Finds and lists all of the TODO, HACK, BUG, etc comment
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
@@ -191,7 +232,7 @@ return {
|
||||
},
|
||||
|
||||
-- TODO: Include hidden files
|
||||
{ "<leader>fT", "<cmd>TodoTelescope<cr>", desc = "List Todo/Fix/Fixme" },
|
||||
{ "<leader>fT", "<cmd>TodoTelescope<cr>", desc = "List Todo/Fix/Fixme" },
|
||||
{ "<leader>ft", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "List Todo" },
|
||||
},
|
||||
},
|
||||
@@ -243,10 +284,10 @@ return {
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>dd", "<cmd>Trouble project_errors toggle focus=true<cr>", desc = "Trouble: Document Diagnostics" },
|
||||
{ "<leader>dw", "<cmd>Trouble most_severe toggle focus=true<cr>", desc = "Trouble: List Project Diagnostics" },
|
||||
{ "<leader>dl", "<cmd>Trouble loclist toggle focus=true<cr>", desc = "Trouble: Location List" },
|
||||
{ "<leader>dq", "<cmd>Trouble quickfix toggle focus=true<cr>", desc = "Trouble: Quickfix List" },
|
||||
{ "gr", "<cmd>Trouble lsp_references toggle focus=true<cr>", desc = "Code: List References" },
|
||||
{ "<leader>dw", "<cmd>Trouble most_severe toggle focus=true<cr>", desc = "Trouble: List Project Diagnostics" },
|
||||
{ "<leader>dl", "<cmd>Trouble loclist toggle focus=true<cr>", desc = "Trouble: Location List" },
|
||||
{ "<leader>dq", "<cmd>Trouble quickfix toggle focus=true<cr>", desc = "Trouble: Quickfix List" },
|
||||
{ "gr", "<cmd>Trouble lsp_references toggle focus=true<cr>", desc = "Code: List References" },
|
||||
{
|
||||
"[q",
|
||||
function()
|
||||
@@ -278,7 +319,6 @@ return {
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
-- LspSaga
|
||||
{
|
||||
"nvimdev/lspsaga.nvim",
|
||||
@@ -297,20 +337,12 @@ return {
|
||||
hide_keyword = true,
|
||||
},
|
||||
lightbulb = {
|
||||
enable = false,
|
||||
sign = false,
|
||||
virtual_text = false,
|
||||
},
|
||||
outline = { auto_preview = false },
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>cR", "<cmd>Lspsaga finder<cr>", { desc = "Code: Goto References" })
|
||||
vim.keymap.set("n", "<leader>cd", "<cmd>Lspsaga peek_definition<cr>",
|
||||
{ desc = "Code: Peek definition: Function" })
|
||||
vim.keymap.set("n", "<leader>cD", "<cmd>Lspsaga peek_type_definition<cr>",
|
||||
{ desc = "Code: Peek definition: Class" })
|
||||
|
||||
vim.keymap.set("n", "K", "<cmd>Lspsaga hover_doc<cr>", { desc = "Hover Documentation" })
|
||||
-- Keymaps in code-lsp.lua
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -381,7 +413,7 @@ return {
|
||||
--
|
||||
-- ["g?"] = actions.help(), -- Open mappings help window
|
||||
{
|
||||
"<leader>o",
|
||||
"<leader>O",
|
||||
function()
|
||||
return require("nvim-navbuddy").open()
|
||||
end,
|
||||
@@ -389,4 +421,131 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Treesitter
|
||||
{
|
||||
-- nvim-treesitter provides parsers for individual languages
|
||||
-- Output of these parses are fed to the NVIM's native treesitter(vim.treesitter)
|
||||
-- What is fed to the native treesitter is essentially the AST
|
||||
-- This AST is then used for syntax-highlighting and many other operations on the code
|
||||
-- Hence, this plugin is only to make installing parsers easier
|
||||
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
init = function(plugin)
|
||||
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
|
||||
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
|
||||
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
|
||||
-- Luckily, the only thing that those plugins need are the custom queries, which we make available
|
||||
-- during startup.
|
||||
require("lazy.core.loader").add_to_rtp(plugin)
|
||||
require("nvim-treesitter.query_predicates")
|
||||
end,
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
config = function()
|
||||
-- When in diff mode, we want to use the default
|
||||
-- vim text objects c & C instead of the treesitter ones.
|
||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
for name, fn in pairs(move) do
|
||||
if name:find("goto") == 1 then
|
||||
move[name] = function(q, ...)
|
||||
if vim.wo.diff then
|
||||
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
||||
for key, query in pairs(config or {}) do
|
||||
if q == query and key:find("[%]%[][cC]") then
|
||||
vim.cmd("normal! " .. key)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
return fn(q, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
config = function()
|
||||
-- See `:help nvim-treesitter`
|
||||
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
|
||||
vim.defer_fn(function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
-- These 2 are required for cmdline
|
||||
"regex",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
},
|
||||
|
||||
auto_install = true,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<C-space>",
|
||||
node_incremental = "<C-space>",
|
||||
scope_incremental = "<C-CR>",
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm (:TSEditQuery textobjects)
|
||||
["aa"] = { query = "@parameter.outer", desc = "Select around the parameter" },
|
||||
["ia"] = { query = "@parameter.inner", desc = "Select inside the parameter" },
|
||||
["af"] = { query = "@function.outer", desc = "Select around the function" },
|
||||
["if"] = { query = "@function.inner", desc = "Select inside of the function" },
|
||||
["ac"] = { query = "@class.outer", desc = "Select around the class" },
|
||||
["ic"] = { query = "@class.inner", desc = "Select inside of the class" },
|
||||
|
||||
["al"] = { query = "@loop.outer", desc = "Select around the loop" },
|
||||
["il"] = { query = "@loop.inner", desc = "Select inside of the loop" },
|
||||
["as"] = { query = "@scope", query_group = "locals", desc = "Select around the scope" },
|
||||
},
|
||||
},
|
||||
|
||||
move = {
|
||||
-- Jump to next and previous text objects
|
||||
enable = true,
|
||||
goto_next_start = {
|
||||
["]f"] = { query = "@function.outer", desc = "Goto next inner function start" },
|
||||
["]c"] = { query = "@class.outer", desc = "Goto next inner class start" },
|
||||
},
|
||||
goto_next_end = {
|
||||
["]F"] = { query = "@function.outer", desc = "Goto next outer function end" },
|
||||
["]C"] = { query = "@class.outer", desc = "Goto next outer class end" },
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" },
|
||||
["[c"] = { query = "@class.outer", desc = "Previous inner class start" },
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" },
|
||||
["[C"] = { query = "@class.outer", desc = "Goto previous outer class start" },
|
||||
},
|
||||
},
|
||||
|
||||
lsp_interop = {
|
||||
enable = true,
|
||||
border = "none",
|
||||
floating_preview_opts = {},
|
||||
-- peek_definition_code = {
|
||||
-- ["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
|
||||
-- ["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
|
||||
-- },
|
||||
},
|
||||
},
|
||||
})
|
||||
end, 0)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -107,17 +107,4 @@ return {
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
-- Git worktree
|
||||
{
|
||||
"ThePrimeagen/git-worktree.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
config = function()
|
||||
-- FIX: Open files do NOT get replaced with the changed branch
|
||||
require("telescope").load_extension("git_worktree")
|
||||
|
||||
vim.keymap.set("n", "<leader>gw",
|
||||
"<cmd> lua require('telescope').extensions.git_worktree.git_worktrees()<CR>")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,81 +1,172 @@
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
-- Define mappings specific for LSP related items.
|
||||
-- It sets the mode, buffer and description for us each time.
|
||||
local on_attach = function(_, bufnr)
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = "LSP: " .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap("<leader>cr", vim.lsp.buf.rename, "Rename Symbol")
|
||||
nmap("<leader>ca", vim.lsp.buf.code_action, "Code Action")
|
||||
nmap("<C-.>", vim.lsp.buf.code_action, "Code Action: VSCode Style")
|
||||
-- See `:help K` for why this keymap
|
||||
-- nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
-- nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap("<leader>cS", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Search Workspace Symbols")
|
||||
nmap("<leader>clf", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, "Workspace List Folders")
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = "Format current buffer with LSP" })
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
-- LSP Configuration & Plugins
|
||||
-- TODO: Disable it for VSCode
|
||||
--
|
||||
-- Main LSP Configuration
|
||||
"neovim/nvim-lspconfig",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
dependencies = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
{ "williamboman/mason.nvim", config = true },
|
||||
{ "williamboman/mason-lspconfig.nvim" },
|
||||
{ "folke/neodev.nvim" },
|
||||
{ "williamboman/mason.nvim", config = true }, -- NOTE: Must be loaded before dependants
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
|
||||
-- Useful status updates for LSP
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
|
||||
-- Allows extra capabilities provided by nvim-cmp
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
config = function()
|
||||
-- Configure LSP
|
||||
-- Every time a new file is opened that is associated with
|
||||
-- an lsp this function will be executed to configure the current buffer
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
-- mason-lspconfig requires that these setup functions are called in this order
|
||||
-- BEFORE setting up the servers.
|
||||
require("mason").setup()
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
mason_lspconfig.setup()
|
||||
-- Lspsaga Keymaps
|
||||
-- Hover Documentation
|
||||
-- Press K 2 times to jump into the hover window
|
||||
-- Place cursor on "View Documentation" gx -> Open the docs on browser
|
||||
map("K", "<cmd>Lspsaga hover_doc<cr>", "Hover Documentation")
|
||||
map("<F2>", vim.lsp.buf.rename, "Rename Symbol")
|
||||
map("<C-.>", "<cmd>Lspsaga code_action<cr>", "Code Actions")
|
||||
map("<leader>ca", "<cmd>Lspsaga code_action<cr>", "Code Actions")
|
||||
-- e to jump to the symbol under cursor; q to quit
|
||||
map("<leader>o", "<cmd>Lspsaga outline<cr>", "Outline Panel on Left")
|
||||
map("<leader>cr", "<cmd>Lspsaga finder<cr>", "Goto References")
|
||||
map("<leader>cpf", "<cmd>Lspsaga peek_definition<cr>", "Peek definition: Function")
|
||||
map("<leader>cpt", "<cmd>Lspsaga peek_type_definition<cr>", "Peek definition: Class")
|
||||
map("<leader>cpi", "<cmd>Lspsaga finder imp<cr>", "Peek: Implementations")
|
||||
|
||||
-- Jump to the definition of the word under your cursor.
|
||||
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||
-- To jump back, press <C-t>.
|
||||
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||
map("<F12>", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||
|
||||
-- Fuzzy find all the symbols in your current document.
|
||||
-- Symbols are things like variables, functions, types, etc.
|
||||
map("<leader>cs", require("telescope.builtin").lsp_document_symbols, "Search Document Symbols")
|
||||
map("<leader>cS", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Search Workspace Symbols")
|
||||
map("<leader>ci", require("telescope.builtin").lsp_implementations, "Goto Implementation")
|
||||
map("<leader>ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition")
|
||||
|
||||
map("<leader>cd", require("telescope.builtin").diagnostics, "List Diagnostics")
|
||||
|
||||
map("<leader>nf", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, "Workspace Folders on Notification")
|
||||
|
||||
-- The following two autocommands are used to highlight references of the
|
||||
-- word under your cursor when your cursor rests there for a little while.
|
||||
-- When you move your cursor, the highlights will be cleared
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- TODO: Make inlay_hint enabled by default
|
||||
-- Change this keymap
|
||||
--
|
||||
-- The following code creates a keymap to toggle inlay hints
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
||||
map("<leader>ni", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
|
||||
end, "Toggle Inlay Hints")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Change diagnostic symbols in the sign column (gutter)
|
||||
if vim.g.have_nerd_font then
|
||||
local signs = { ERROR = "", WARN = "", INFO = "", HINT = "" }
|
||||
local diagnostic_signs = {}
|
||||
for type, icon in pairs(signs) do
|
||||
diagnostic_signs[vim.diagnostic.severity[type]] = icon
|
||||
end
|
||||
vim.diagnostic.config({ signs = { text = diagnostic_signs } })
|
||||
end
|
||||
|
||||
-- LSP servers and clients are able to communicate to each other what features they support.
|
||||
-- By default, Neovim doesn't support everything that is in the LSP specification.
|
||||
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
|
||||
-- Here, we broadcast the new capabilities to the servers.
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
|
||||
|
||||
-- Enable the following language servers
|
||||
-- Add any additional override configuration in the following tables. They will be passed to the `settings` field of the server config
|
||||
-- If you want to override the default filetypes that your language server will attach to you can define the property 'filetypes' to the map in question.
|
||||
-- Add any additional override configuration in the following tables. Available keys are:
|
||||
-- - cmd (table): Override the default command used to start the server
|
||||
-- - filetypes (table): Override the default list of associated filetypes for the server
|
||||
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
|
||||
-- - settings (table): Override the default settings passed when initializing the server.
|
||||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||
local servers = {
|
||||
html = { filetypes = { "html", "twig", "hbs" } },
|
||||
cssls = {},
|
||||
jsonls = {},
|
||||
|
||||
bashls = { filetypes = { "sh", "bash", "zsh" } },
|
||||
pylsp = {},
|
||||
ts_ls = {},
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
completion = { callSnippet = "Replace" },
|
||||
hint = { enable = true },
|
||||
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
||||
-- diagnostics = { disable = { 'missing-fields' } },
|
||||
-- cmd = { ... },
|
||||
-- filetypes = { ... },
|
||||
-- capabilities = {},
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
completion = { callSnippet = "Replace" },
|
||||
hint = { enable = true },
|
||||
diagnostics = { disable = { "missing-fields" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
bashls = { filetypes = { "sh", "bash", "zsh" } },
|
||||
html = { filetypes = { "html", "twig", "hbs" } },
|
||||
omnisharp = {
|
||||
settings = {
|
||||
DotNet = {
|
||||
enablePackageRestore = true,
|
||||
FormattingOptions = { OrganizeImports = true },
|
||||
RoslynExtensionOptions = {
|
||||
EnableAnalyzerSupport = true,
|
||||
EnableImportCompletion = true,
|
||||
},
|
||||
Sdk = { IncludePrereleases = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
sqlls = {},
|
||||
dockerls = {},
|
||||
docker_compose_language_service = {},
|
||||
|
||||
marksman = {},
|
||||
ltex = {
|
||||
filetypes = { "markdown", "text" },
|
||||
flags = { debounce_text_changes = 3000 },
|
||||
@@ -95,52 +186,35 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
omnisharp = {
|
||||
-- DotNet = {
|
||||
-- enablePackageRestore = true,
|
||||
-- },
|
||||
settings = {
|
||||
FormattingOptions = {
|
||||
OrganizeImports = true,
|
||||
},
|
||||
RoslynExtensionOptions = {
|
||||
EnableAnalyzerSupport = true,
|
||||
EnableImportCompletion = true,
|
||||
},
|
||||
Sdk = {
|
||||
IncludePrereleases = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- https://github.com/joe-re/sql-language-server?tab=readme-ov-file#configuration
|
||||
sqlls = {},
|
||||
marksman = {},
|
||||
cssls = {},
|
||||
dockerls = {},
|
||||
docker_compose_language_service = {},
|
||||
jsonls = {},
|
||||
pylsp = {},
|
||||
}
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
-- Ensure the servers and tools above are installed
|
||||
require("mason").setup()
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
-- Add other tools here that you want Mason to install for you
|
||||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
vim.list_extend(ensure_installed, {
|
||||
"stylua",
|
||||
"codespell",
|
||||
"bash-language-server",
|
||||
"marksman",
|
||||
"html-lsp",
|
||||
"css-lsp",
|
||||
"dockerfile-language-server",
|
||||
"python-lsp-server",
|
||||
})
|
||||
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
||||
|
||||
mason_lspconfig.setup_handlers({
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup({
|
||||
inlay_hints = { enabled = true },
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
diagnostics = {
|
||||
require("mason-lspconfig").setup({
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local server = servers[server_name] or {}
|
||||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
||||
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
|
||||
server.inlay_hints = { enabled = true }
|
||||
server.diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = {
|
||||
@@ -149,17 +223,10 @@ return {
|
||||
prefix = "●",
|
||||
},
|
||||
severity_sort = true,
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = require("config.util").icons.diagnostics.Error,
|
||||
[vim.diagnostic.severity.WARN] = require("config.util").icons.diagnostics.Warn,
|
||||
[vim.diagnostic.severity.HINT] = require("config.util").icons.diagnostics.Hint,
|
||||
[vim.diagnostic.severity.INFO] = require("config.util").icons.diagnostics.Info,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
require("lspconfig")[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
@@ -169,11 +236,11 @@ return {
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
opts = {
|
||||
progress = {
|
||||
poll_rate = 1, -- How and when to poll for progress messages
|
||||
suppress_on_insert = true, -- Suppress new messages while in insert mode
|
||||
ignore_done_already = true, -- Ignore new tasks that are already complete
|
||||
poll_rate = 1, -- How and when to poll for progress messages
|
||||
suppress_on_insert = true, -- Suppress new messages while in insert mode
|
||||
ignore_done_already = true, -- Ignore new tasks that are already complete
|
||||
ignore_empty_message = true, -- Ignore new tasks that don't contain a message
|
||||
ignore = {}, -- List of LSP servers to ignore
|
||||
ignore = {}, -- List of LSP servers to ignore
|
||||
|
||||
display = {
|
||||
render_limit = 1, -- How many LSP messages to show at once
|
||||
@@ -182,7 +249,7 @@ return {
|
||||
},
|
||||
|
||||
notification = {
|
||||
poll_rate = 2, -- How often to udate and render notifications
|
||||
poll_rate = 2, -- How often to udate and render notifications
|
||||
filter = vim.log.levels.WARN, -- Minimum notifications level
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,170 +1,4 @@
|
||||
return {
|
||||
{ "easymotion/vim-easymotion" },
|
||||
{ "unblevable/quick-scope" },
|
||||
|
||||
-- Automatically highlights other instances of the word under cursor
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
lazy = false,
|
||||
opts = {
|
||||
delay = 200,
|
||||
large_file_cutoff = 2000,
|
||||
large_file_override = {
|
||||
providers = { "lsp" },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- Copied from LazyNvim
|
||||
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" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Treesitter
|
||||
{
|
||||
-- nvim-treesitter provides parsers for individual languages
|
||||
-- Output of these parses are fed to the NVIM's native treesitter(vim.treesitter)
|
||||
-- What is fed to the native treesitter is essentially the AST
|
||||
-- This AST is then used for syntax-highlighting and many other operations on the code
|
||||
-- Hence, this plugin is only to make installing parsers easier
|
||||
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
init = function(plugin)
|
||||
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
|
||||
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
|
||||
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
|
||||
-- Luckily, the only thing that those plugins need are the custom queries, which we make available
|
||||
-- during startup.
|
||||
require("lazy.core.loader").add_to_rtp(plugin)
|
||||
require("nvim-treesitter.query_predicates")
|
||||
end,
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
config = function()
|
||||
-- When in diff mode, we want to use the default
|
||||
-- vim text objects c & C instead of the treesitter ones.
|
||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
for name, fn in pairs(move) do
|
||||
if name:find("goto") == 1 then
|
||||
move[name] = function(q, ...)
|
||||
if vim.wo.diff then
|
||||
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
||||
for key, query in pairs(config or {}) do
|
||||
if q == query and key:find("[%]%[][cC]") then
|
||||
vim.cmd("normal! " .. key)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
return fn(q, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
config = function()
|
||||
-- See `:help nvim-treesitter`
|
||||
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
|
||||
vim.defer_fn(function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
-- These 2 are required for cmdline
|
||||
"regex",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
},
|
||||
|
||||
auto_install = true,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<C-space>",
|
||||
node_incremental = "<C-space>",
|
||||
scope_incremental = "<C-CR>",
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm (:TSEditQuery textobjects)
|
||||
["aa"] = { query = "@parameter.outer", desc = "Select around the parameter" },
|
||||
["ia"] = { query = "@parameter.inner", desc = "Select inside the parameter" },
|
||||
["af"] = { query = "@function.outer", desc = "Select around the function" },
|
||||
["if"] = { query = "@function.inner", desc = "Select inside of the function" },
|
||||
["ac"] = { query = "@class.outer", desc = "Select around the class" },
|
||||
["ic"] = { query = "@class.inner", desc = "Select inside of the class" },
|
||||
|
||||
["al"] = { query = "@loop.outer", desc = "Select around the loop" },
|
||||
["il"] = { query = "@loop.inner", desc = "Select inside of the loop" },
|
||||
["as"] = { query = "@scope", query_group = "locals", desc = "Select around the scope" },
|
||||
},
|
||||
},
|
||||
|
||||
move = {
|
||||
-- Jump to next and previous text objects
|
||||
enable = true,
|
||||
goto_next_start = {
|
||||
["]f"] = { query = "@function.outer", desc = "Goto next inner function start" },
|
||||
["]c"] = { query = "@class.outer", desc = "Goto next inner class start" },
|
||||
},
|
||||
goto_next_end = {
|
||||
["]F"] = { query = "@function.outer", desc = "Goto next outer function end" },
|
||||
["]C"] = { query = "@class.outer", desc = "Goto next outer class end" },
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" },
|
||||
["[c"] = { query = "@class.outer", desc = "Previous inner class start" },
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" },
|
||||
["[C"] = { query = "@class.outer", desc = "Goto previous outer class start" },
|
||||
},
|
||||
},
|
||||
|
||||
lsp_interop = {
|
||||
enable = true,
|
||||
border = "none",
|
||||
floating_preview_opts = {},
|
||||
-- peek_definition_code = {
|
||||
-- ["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
|
||||
-- ["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
|
||||
-- },
|
||||
},
|
||||
},
|
||||
})
|
||||
end, 0)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ return {
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
branch = "v3.x",
|
||||
keys = {
|
||||
{ "<leader><tab>", "<CMD>Neotree toggle left<CR>", desc = "Open NeoTree Explorer at Git root", remap = true },
|
||||
{ "<leader>e", "<CMD>Neotree toggle float<CR>", desc = "Open NeoTree on Floating Window", remap = true },
|
||||
{ "<leader><tab>", "<CMD>Neotree toggle left<CR>", desc = "Open NeoTree Explorer at Git root", remap = true },
|
||||
{ "<leader>e", "<CMD>Neotree toggle float<CR>", desc = "Open NeoTree on Floating Window", remap = true },
|
||||
|
||||
{
|
||||
"<leader>be",
|
||||
@@ -46,10 +46,10 @@ return {
|
||||
},
|
||||
window = {
|
||||
position = "left",
|
||||
width = 30, -- Saner window size
|
||||
width = 30, -- Saner window size
|
||||
mappings = {
|
||||
["s"] = "open_split", -- horizontal split
|
||||
["v"] = "open_vsplit", -- vertical split
|
||||
["s"] = "open_split", -- horizontal split
|
||||
["v"] = "open_vsplit", -- vertical split
|
||||
["Y"] = function(state) -- Copy file's path to + register
|
||||
local node = state.tree:get_node()
|
||||
local path = node:get_id()
|
||||
@@ -59,7 +59,7 @@ return {
|
||||
},
|
||||
default_component_configs = {
|
||||
indent = {
|
||||
indent_size = 2, -- Compact tree display
|
||||
indent_size = 2, -- Compact tree display
|
||||
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
|
||||
expander_collapsed = "",
|
||||
expander_expanded = "",
|
||||
@@ -79,7 +79,7 @@ return {
|
||||
local events = require("neo-tree.events")
|
||||
opts.event_handlers = opts.event_handlers or {}
|
||||
vim.list_extend(opts.event_handlers, {
|
||||
{ event = events.FILE_MOVED, handler = on_move },
|
||||
{ event = events.FILE_MOVED, handler = on_move },
|
||||
{ event = events.FILE_RENAMED, handler = on_move },
|
||||
})
|
||||
require("neo-tree").setup(opts)
|
||||
@@ -110,8 +110,9 @@ return {
|
||||
},
|
||||
"nvim-telescope/telescope-ui-select.nvim",
|
||||
{
|
||||
"nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font
|
||||
}
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
enabled = vim.g.have_nerd_font,
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
-- NOTE: Search in hidden files trick taken from: https://stackoverflow.com/a/75500661/11057673
|
||||
@@ -158,9 +159,7 @@ return {
|
||||
pcall(require("telescope").load_extension, "fzf")
|
||||
pcall(require("telescope").load_extension, "ui-select")
|
||||
|
||||
-- Special Things: Telescope
|
||||
vim.keymap.set("n", "<leader>nc", require("telescope.builtin").colorscheme,
|
||||
{ desc = "List Neovim Colorschemes (with preview)" })
|
||||
-- Keymaps for LSP Things -> In code-lsp.lua
|
||||
|
||||
-- Grep things -> Search
|
||||
vim.keymap.set("n", "<leader>sb", function()
|
||||
@@ -169,55 +168,31 @@ return {
|
||||
prompt_title = "Live Grep in Open Files",
|
||||
})
|
||||
end, { desc = "Search Open Buffers" })
|
||||
vim.keymap.set("n", "<leader>sg", require("telescope.builtin").live_grep,
|
||||
{ desc = "Search/LiveGrep the Project" })
|
||||
vim.keymap.set("n", "<C-a-f>", require("telescope.builtin").live_grep,
|
||||
{ desc = "Search/LiveGrep the Project" })
|
||||
vim.keymap.set("n", "<leader>sw", require("telescope.builtin").grep_string,
|
||||
{ desc = "Search current Word in Project" })
|
||||
vim.keymap.set("n", "<leader>sg", require("telescope.builtin").live_grep, { desc = "Search/LiveGrep the Project" })
|
||||
vim.keymap.set("n", "<C-a-f>", require("telescope.builtin").live_grep, { desc = "Search/LiveGrep the Project" })
|
||||
vim.keymap.set("n", "<leader>sw", require("telescope.builtin").grep_string, { desc = "Search current Word in Project" })
|
||||
|
||||
-- List
|
||||
vim.keymap.set("n", "<leader>fb", require("telescope.builtin").buffers, { desc = "List Buffers" })
|
||||
vim.keymap.set("n", "<leader>fc", require("telescope.builtin").command_history,
|
||||
{ desc = "List NeoVIM Command History" })
|
||||
vim.keymap.set("n", "<C-a-p>", require("telescope.builtin").find_files, { desc = "List & Search Files" })
|
||||
vim.keymap.set("n", "<leader>ff", require("telescope.builtin").find_files, { desc = "List & Search Files" })
|
||||
vim.keymap.set("n", "<leader>fn", require("telescope.builtin").help_tags,
|
||||
{ desc = "List & Search NeoVIM Help" })
|
||||
vim.keymap.set("n", "<leader>fq", require("telescope.builtin").quickfixhistory,
|
||||
{ desc = "List Quickfix History" })
|
||||
vim.keymap.set("n", "<leader>fs", require("telescope.builtin").search_history,
|
||||
{ desc = "List Search History" })
|
||||
vim.keymap.set("n", "<leader>fq", require("telescope.builtin").quickfixhistory, { desc = "List Quickfix History" })
|
||||
|
||||
-- Git
|
||||
vim.keymap.set("n", "<leader>gfb", require("telescope.builtin").git_branches, { desc = "List Git Branches" })
|
||||
vim.keymap.set("n", "<leader>gfc", require("telescope.builtin").git_commits, { desc = "List Git Commits" })
|
||||
|
||||
-- LSP Things -> Coding
|
||||
vim.keymap.set("n", "<leader>cld", require("telescope.builtin").diagnostics,
|
||||
{ desc = "Code: List Diagnostics" })
|
||||
|
||||
vim.keymap.set("n", "<leader>ci", require("telescope.builtin").lsp_implementations,
|
||||
{ desc = "Code: Goto Implementation" })
|
||||
|
||||
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "Code: Goto Definition" })
|
||||
vim.keymap.set("n", "<leader>ct", require("telescope.builtin").lsp_type_definitions,
|
||||
{ desc = "Code: Goto Type Definition" })
|
||||
-- vim.keymap.set("n", "<leader>cgD", vim.lsp.buf.declaration, { desc = "Goto Declaration" })
|
||||
|
||||
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references,
|
||||
{ desc = "Code: Goto References" })
|
||||
-- vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references, { desc = "Code: List References for word under cursor" })
|
||||
|
||||
vim.keymap.set("n", "<leader>O", require("telescope.builtin").lsp_workspace_symbols,
|
||||
{ desc = "Code: Search Workspace Symbols" })
|
||||
|
||||
vim.keymap.set("n", "<leader>nk", require("telescope.builtin").keymaps,
|
||||
{ desc = "List & Search NeoVIM Keymaps" })
|
||||
vim.keymap.set("n", "<leader>nm", require("telescope.builtin").man_pages,
|
||||
{ desc = "List & Search System Man Pages" })
|
||||
-- Neovim Things
|
||||
vim.keymap.set("n", "<leader>ns", require("telescope.builtin").search_history, { desc = "List Search History" })
|
||||
vim.keymap.set("n", "<leader>nn", require("telescope.builtin").help_tags, { desc = "List & Search NeoVIM Help" })
|
||||
vim.keymap.set("n", "<leader>nc", require("telescope.builtin").command_history, { desc = "List NeoVIM Command History" })
|
||||
vim.keymap.set("n", "<leader>nC", require("telescope.builtin").colorscheme, { desc = "List Neovim Colorschemes (with preview)" })
|
||||
vim.keymap.set("n", "<leader>nn", "<cmd>Telescope notify<cr>", { desc = "List past notifications" })
|
||||
vim.keymap.set("n", "<leader>nv", require("telescope.builtin").vim_options, { desc = "List Vim Options" })
|
||||
|
||||
-- Help
|
||||
vim.keymap.set("n", "<leader>hk", require("telescope.builtin").keymaps, { desc = "Help: NeoVIM Keymaps" })
|
||||
vim.keymap.set("n", "<leader>hm", require("telescope.builtin").man_pages, { desc = "Help: System Man Pages" })
|
||||
vim.keymap.set("n", "<leader>hv", require("telescope.builtin").vim_options, { desc = "Help: Vim Options" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ return {
|
||||
},
|
||||
event = "VeryLazy",
|
||||
keys = {
|
||||
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle buffer-pin" },
|
||||
{ "<leader>bj", "<Cmd>BufferLinePick<CR>", desc = "Choose and jump to a buffer" },
|
||||
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle buffer-pin" },
|
||||
{ "<leader>bX", "<Cmd>BufferLineCloseOthers<CR>", desc = "Close other buffers" },
|
||||
{ "<leader>xo", "<Cmd>BufferLineCloseOthers<CR>", desc = "Close other buffers" },
|
||||
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev buffer" },
|
||||
{ "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next buffer" },
|
||||
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev buffer" },
|
||||
{ "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next buffer" },
|
||||
},
|
||||
opts = {
|
||||
options = {
|
||||
@@ -69,6 +69,11 @@ return {
|
||||
local buf_line = require("bufferline")
|
||||
buf_line.setup(opts)
|
||||
|
||||
-- <alt+1> ... <alt+9> to switch to a buffer
|
||||
for i = 1, 9 do
|
||||
vim.keymap.set("n", string.format("<A-%s>", i), string.format("<cmd>BufferLineGoToBuffer %s<CR>", i), { noremap = true, silent = true })
|
||||
end
|
||||
|
||||
-- Fix bufferline when restoring a session
|
||||
vim.api.nvim_create_autocmd("BufAdd", {
|
||||
callback = function()
|
||||
@@ -288,7 +293,7 @@ return {
|
||||
},
|
||||
|
||||
lualine_y = {
|
||||
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
|
||||
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
|
||||
{ "location", padding = { left = 0, right = 1 } },
|
||||
},
|
||||
lualine_z = {
|
||||
|
||||
@@ -1,180 +1,4 @@
|
||||
local M = {}
|
||||
---@type table<string, table<string, string[]>>
|
||||
M.dials_by_ft = {}
|
||||
|
||||
---@param increment boolean
|
||||
---@param g? boolean
|
||||
function M.dial(increment, g)
|
||||
local mode = vim.fn.mode(true)
|
||||
-- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22'
|
||||
local is_visual = mode == "v" or mode == "V" or mode == "\22"
|
||||
local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal")
|
||||
local group = M.dials_by_ft[vim.bo.filetype] or "default"
|
||||
return require("dial.map")[func](group)
|
||||
end
|
||||
|
||||
return {
|
||||
-- Better increment/decrement with <Ctrl+a>
|
||||
{
|
||||
"monaqa/dial.nvim",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<C-a>", function() return M.dial(true) end, expr = true, desc = "Increment", mode = { "n", "v" } },
|
||||
{ "<C-x>", function() return M.dial(false) end, expr = true, desc = "Decrement", mode = { "n", "v" } },
|
||||
{ "g<C-a>", function() return M.dial(true, true) end, expr = true, desc = "Increment", mode = { "n", "v" } },
|
||||
{ "g<C-x>", function() return M.dial(false, true) end, expr = true, desc = "Decrement", mode = { "n", "v" } },
|
||||
},
|
||||
opts = function()
|
||||
local augend = require("dial.augend")
|
||||
|
||||
local logical_alias = augend.constant.new({
|
||||
elements = { "&&", "||" },
|
||||
word = false,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local ordinal_numbers = augend.constant.new({
|
||||
-- elements through which we cycle. When we increment, we go down
|
||||
-- On decrement we go up
|
||||
elements = {
|
||||
"first",
|
||||
"second",
|
||||
"third",
|
||||
"fourth",
|
||||
"fifth",
|
||||
"sixth",
|
||||
"seventh",
|
||||
"eighth",
|
||||
"ninth",
|
||||
"tenth",
|
||||
},
|
||||
-- if true, it only matches strings with word boundary. firstDate wouldn't work for example
|
||||
word = false,
|
||||
-- do we cycle back and forth (tenth to first on increment, first to tenth on decrement).
|
||||
-- Otherwise nothing will happen when there are no further values
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local weekdays = augend.constant.new({
|
||||
elements = {
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local months = augend.constant.new({
|
||||
elements = {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local capitalized_boolean = augend.constant.new({
|
||||
elements = {
|
||||
"True",
|
||||
"False",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
return {
|
||||
dials_by_ft = {
|
||||
css = "css",
|
||||
javascript = "typescript",
|
||||
javascriptreact = "typescript",
|
||||
json = "json",
|
||||
lua = "lua",
|
||||
markdown = "markdown",
|
||||
python = "python",
|
||||
sass = "css",
|
||||
scss = "css",
|
||||
typescript = "typescript",
|
||||
typescriptreact = "typescript",
|
||||
cs = "csharp",
|
||||
},
|
||||
groups = {
|
||||
default = {
|
||||
augend.integer.alias.decimal, -- nonnegative decimal number (0, 1, 2, 3, ...)
|
||||
augend.integer.alias.hex, -- nonnegative hex number (0x01, 0x1a1f, etc.)
|
||||
augend.date.alias["%Y/%m/%d"], -- date (2022/02/19, etc.)
|
||||
},
|
||||
typescript = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.constant.alias.bool, -- boolean value (true <-> false)
|
||||
logical_alias,
|
||||
augend.constant.new({ elements = { "let", "const" } }),
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
css = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.hexcolor.new({
|
||||
case = "lower",
|
||||
}),
|
||||
augend.hexcolor.new({
|
||||
case = "upper",
|
||||
}),
|
||||
},
|
||||
markdown = {
|
||||
augend.misc.alias.markdown_header,
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
json = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.semver.alias.semver, -- versioning (v1.1.2)
|
||||
},
|
||||
lua = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.constant.alias.bool, -- boolean value (true <-> false)
|
||||
augend.constant.new({
|
||||
elements = { "and", "or" },
|
||||
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
|
||||
cyclic = true, -- "or" is incremented into "and".
|
||||
}),
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
python = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
capitalized_boolean,
|
||||
logical_alias,
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("dial.config").augends:register_group(opts.groups)
|
||||
M.dials_by_ft = opts.dials_by_ft
|
||||
end,
|
||||
},
|
||||
|
||||
-- Navigate between NVIM & Tmux splits seamlessly
|
||||
{
|
||||
"christoomey/vim-tmux-navigator",
|
||||
@@ -231,50 +55,11 @@ return {
|
||||
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
dependencies = {
|
||||
"echasnovski/mini.icons",
|
||||
},
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>r"] = { name = "+refactor" },
|
||||
},
|
||||
icons = {
|
||||
-- set icon mappings to true if you have a Nerd Font
|
||||
mappings = vim.g.have_nerd_font,
|
||||
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
|
||||
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
|
||||
keys = vim.g.have_nerd_font and {} or {
|
||||
Up = '<Up> ',
|
||||
Down = '<Down> ',
|
||||
Lefj = '<Left> ',
|
||||
Right = '<Right> ',
|
||||
C = '<C-…> ',
|
||||
M = '<M-…> ',
|
||||
D = '<D-…> ',
|
||||
S = '<S-…> ',
|
||||
CR = '<CR> ',
|
||||
Esc = '<Esc> ',
|
||||
ScrollWheelDown = '<ScrollWheelDown> ',
|
||||
ScrollWheelUp = '<ScrollWheelUp> ',
|
||||
NL = '<NL> ',
|
||||
BS = '<BS> ',
|
||||
Space = '<Space> ',
|
||||
Tab = '<Tab> ',
|
||||
F1 = '<F1>',
|
||||
F2 = '<F2>',
|
||||
F3 = '<F3>',
|
||||
F4 = '<F4>',
|
||||
F5 = '<F5>',
|
||||
F6 = '<F6>',
|
||||
F7 = '<F7>',
|
||||
F8 = '<F8>',
|
||||
F9 = '<F9>',
|
||||
F10 = '<F10>',
|
||||
F11 = '<F11>',
|
||||
F12 = '<F12>',
|
||||
},
|
||||
},
|
||||
|
||||
-- Document existing key chains
|
||||
spec = {
|
||||
{ "<leader>c", group = "Code" },
|
||||
@@ -283,8 +68,9 @@ return {
|
||||
{ "<leader>f", group = "File Operations" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>f", group = "Find and List Things" },
|
||||
{ "<leader>h", group = "Help" },
|
||||
{ "<leader>n", group = "NVIM Things" },
|
||||
{ "<leader>q", group = "Database Query" },
|
||||
{ "<leader>q", group = "Database" },
|
||||
{ "<leader>s", group = "Search/Grep Things" },
|
||||
{ "<leader>t", group = "Unit Test Operations" },
|
||||
{ "<leader>x", group = "Delete/Remove Something" },
|
||||
@@ -296,6 +82,7 @@ return {
|
||||
-- TIP: autocmd to autoload sessions at: ../config/autocmd.lua
|
||||
{
|
||||
"folke/persistence.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
-- Session files stored at: ~/.config/nvim/sessions/
|
||||
|
||||
Reference in New Issue
Block a user