Skip to content

Commit 31a4a00

Browse files
theopnvencronys
authored andcommitted
Change LSP Keybindings to Match the Default gr Bindings Introduced in Neovim 0.11 (nvim-lua#1427)
* refactor: change LSP keybindings to the default gr bindings introduced in 0.11 * refactor: modify existing LSP functions to follow convention
1 parent 2ca842a commit 31a4a00

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

init.lua

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,7 @@ require('lazy').setup({
385385

386386
-- Document existing key chains
387387
spec = {
388-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
389-
{ '<leader>d', group = '[D]ocument' },
390-
{ '<leader>r', group = '[R]ename' },
391388
{ '<leader>s', group = '[S]earch' },
392-
{ '<leader>w', group = '[W]orkspace' },
393389
{ '<leader>t', group = '[T]oggle' },
394390
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
395391
},
@@ -581,42 +577,42 @@ require('lazy').setup({
581577
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
582578
end
583579

584-
-- Jump to the definition of the word under your cursor.
585-
-- This is where a variable was first declared, or where a function is defined, etc.
586-
-- To jump back, press <C-t>.
587-
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
580+
-- Rename the variable under your cursor.
581+
-- Most Language Servers support renaming across files, etc.
582+
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
583+
584+
-- Execute a code action, usually your cursor needs to be on top of an error
585+
-- or a suggestion from your LSP for this to activate.
586+
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
588587

589588
-- Find references for the word under your cursor.
590-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
589+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
591590

592591
-- Jump to the implementation of the word under your cursor.
593592
-- Useful when your language has ways of declaring types without an actual implementation.
594-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
593+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
595594

596-
-- Jump to the type of the word under your cursor.
597-
-- Useful when you're not sure what type a variable is and you want to see
598-
-- the definition of its *type*, not where it was *defined*.
599-
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
595+
-- Jump to the definition of the word under your cursor.
596+
-- This is where a variable was first declared, or where a function is defined, etc.
597+
-- To jump back, press <C-t>.
598+
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
599+
600+
-- WARN: This is not Goto Definition, this is Goto Declaration.
601+
-- For example, in C this would take you to the header.
602+
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
600603

601604
-- Fuzzy find all the symbols in your current document.
602605
-- Symbols are things like variables, functions, types, etc.
603-
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
606+
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
604607

605608
-- Fuzzy find all the symbols in your current workspace.
606609
-- Similar to document symbols, except searches over your entire project.
607-
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
608-
609-
-- Rename the variable under your cursor.
610-
-- Most Language Servers support renaming across files, etc.
611-
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
612-
613-
-- Execute a code action, usually your cursor needs to be on top of an error
614-
-- or a suggestion from your LSP for this to activate.
615-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
610+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
616611

617-
-- WARN: This is not Goto Definition, this is Goto Declaration.
618-
-- For example, in C this would take you to the header.
619-
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
612+
-- Jump to the type of the word under your cursor.
613+
-- Useful when you're not sure what type a variable is and you want to see
614+
-- the definition of its *type*, not where it was *defined*.
615+
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
620616

621617
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
622618
---@param client vim.lsp.Client

0 commit comments

Comments
 (0)