nvim: Add keybindings for LSP

LSP has a lot of functionality that I would benefit from taking
advantage of, this adds bindings for a bunch of that and which-key
support so I can figure out which key does what.

Signed-off-by: Nicholas Mello <nick@nmello.dev>
This commit is contained in:
2025-08-14 23:13:02 -05:00
parent 567cf33f55
commit 1273ad4779
3 changed files with 62 additions and 1 deletions

View File

@@ -12,5 +12,6 @@
"oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}

View File

@@ -7,6 +7,47 @@ vim.api.nvim_create_autocmd("BufWritePre", {
return {
{
"neovim/nvim-lspconfig",
keys = {
-- Navigation
{ "<leader>dgd", vim.lsp.buf.definition, desc = "Go to Definition" },
{ "<leader>dgD", vim.lsp.buf.declaration, desc = "Go to Declaration" },
{ "<leader>dgi", vim.lsp.buf.implementation, desc = "Go to Implementation" },
{ "<leader>dgt", vim.lsp.buf.type_definition, desc = "Go to Type Definition" },
{ "<leader>dgr", vim.lsp.buf.references, desc = "List References" },
{ "<leader>dgs", vim.lsp.buf.document_symbol, desc = "Document Symbols" },
{ "<leader>dgS", vim.lsp.buf.workspace_symbol, desc = "Workspace Symbols" },
-- Hover & help
{ "<leader>dgh", vim.lsp.buf.hover, desc = "Hover Documentation" },
{ "<leader>dgsig", vim.lsp.buf.signature_help, desc = "Signature Help" },
-- Refactoring
{ "<leader>drn", vim.lsp.buf.rename, desc = "Rename Symbol" },
{ "<leader>dca", vim.lsp.buf.code_action, desc = "Code Action" },
{
"<leader>doi",
function()
vim.lsp.buf.code_action({
context = {
only = { "source.organizeImports" },
diagnostics = {},
}
})
end,
desc = "Organize Imports"
},
-- Diagnostics
{ "<leader>de", vim.diagnostic.open_float, desc = "Show Line Diagnostics" },
{ "<leader>ddl", vim.diagnostic.setloclist, desc = "List Diagnostics" },
-- Formatting
{ "<leader>df", function() vim.lsp.buf.format({ async = true }) end, desc = "Format Document" },
-- Advanced: highlight usage
{ "<leader>dhl", vim.lsp.buf.document_highlight, desc = "Highlight Symbol" },
{ "<leader>dhc", vim.lsp.buf.clear_references, desc = "Clear Highlights" },
},
dependencies = {
{
"folke/lazydev.nvim",

View File

@@ -0,0 +1,19 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
triggers = { "<leader>", " " },
defaults = {
["<leader>d"] = { name = "+LSP" },
},
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}