diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 0d0f601..366bb2f 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -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" } } diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 2e615ef..7b2fbd8 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -7,6 +7,47 @@ vim.api.nvim_create_autocmd("BufWritePre", { return { { "neovim/nvim-lspconfig", + keys = { + -- Navigation + { "dgd", vim.lsp.buf.definition, desc = "Go to Definition" }, + { "dgD", vim.lsp.buf.declaration, desc = "Go to Declaration" }, + { "dgi", vim.lsp.buf.implementation, desc = "Go to Implementation" }, + { "dgt", vim.lsp.buf.type_definition, desc = "Go to Type Definition" }, + { "dgr", vim.lsp.buf.references, desc = "List References" }, + { "dgs", vim.lsp.buf.document_symbol, desc = "Document Symbols" }, + { "dgS", vim.lsp.buf.workspace_symbol, desc = "Workspace Symbols" }, + + -- Hover & help + { "dgh", vim.lsp.buf.hover, desc = "Hover Documentation" }, + { "dgsig", vim.lsp.buf.signature_help, desc = "Signature Help" }, + + -- Refactoring + { "drn", vim.lsp.buf.rename, desc = "Rename Symbol" }, + { "dca", vim.lsp.buf.code_action, desc = "Code Action" }, + { + "doi", + function() + vim.lsp.buf.code_action({ + context = { + only = { "source.organizeImports" }, + diagnostics = {}, + } + }) + end, + desc = "Organize Imports" + }, + + -- Diagnostics + { "de", vim.diagnostic.open_float, desc = "Show Line Diagnostics" }, + { "ddl", vim.diagnostic.setloclist, desc = "List Diagnostics" }, + + -- Formatting + { "df", function() vim.lsp.buf.format({ async = true }) end, desc = "Format Document" }, + + -- Advanced: highlight usage + { "dhl", vim.lsp.buf.document_highlight, desc = "Highlight Symbol" }, + { "dhc", vim.lsp.buf.clear_references, desc = "Clear Highlights" }, + }, dependencies = { { "folke/lazydev.nvim", diff --git a/nvim/lua/plugins/whichkey.lua b/nvim/lua/plugins/whichkey.lua new file mode 100644 index 0000000..57708e3 --- /dev/null +++ b/nvim/lua/plugins/whichkey.lua @@ -0,0 +1,19 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + triggers = { "", " " }, + defaults = { + ["d"] = { name = "+LSP" }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +}