Skip to content

Commit 1de43f9

Browse files
theopnGabrielTorland
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 b804d9f commit 1de43f9

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
@@ -360,11 +360,7 @@ require('lazy').setup({
360360

361361
-- Document existing key chains
362362
spec = {
363-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
364-
{ '<leader>d', group = '[D]ocument' },
365-
{ '<leader>r', group = '[R]ename' },
366363
{ '<leader>s', group = '[S]earch' },
367-
{ '<leader>w', group = '[W]orkspace' },
368364
{ '<leader>t', group = '[T]oggle' },
369365
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
370366
},
@@ -759,42 +755,42 @@ require('lazy').setup({
759755
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
760756
end
761757

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

767766
-- Find references for the word under your cursor.
768-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
767+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
769768

770769
-- Jump to the implementation of the word under your cursor.
771770
-- Useful when your language has ways of declaring types without an actual implementation.
772-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
771+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
773772

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

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

783786
-- Fuzzy find all the symbols in your current workspace.
784787
-- Similar to document symbols, except searches over your entire project.
785-
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
786-
787-
-- Rename the variable under your cursor.
788-
-- Most Language Servers support renaming across files, etc.
789-
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
790-
791-
-- Execute a code action, usually your cursor needs to be on top of an error
792-
-- or a suggestion from your LSP for this to activate.
793-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
788+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
794789

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

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

0 commit comments

Comments
 (0)