Skip to content

Commit 6aef8ff

Browse files
theopnLogan Lang
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 1d43894 commit 6aef8ff

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

356356
-- Document existing key chains
357357
spec = {
358-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
359-
{ '<leader>d', group = '[D]ocument' },
360-
{ '<leader>r', group = '[R]ename' },
361358
{ '<leader>s', group = '[S]earch' },
362-
{ '<leader>w', group = '[W]orkspace' },
363359
{ '<leader>t', group = '[T]oggle' },
364360
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
365361
},
@@ -551,42 +547,42 @@ require('lazy').setup({
551547
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
552548
end
553549

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

559558
-- Find references for the word under your cursor.
560-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
559+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
561560

562561
-- Jump to the implementation of the word under your cursor.
563562
-- Useful when your language has ways of declaring types without an actual implementation.
564-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
563+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
565564

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

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

575578
-- Fuzzy find all the symbols in your current workspace.
576579
-- Similar to document symbols, except searches over your entire project.
577-
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
578-
579-
-- Rename the variable under your cursor.
580-
-- Most Language Servers support renaming across files, etc.
581-
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
582-
583-
-- Execute a code action, usually your cursor needs to be on top of an error
584-
-- or a suggestion from your LSP for this to activate.
585-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
580+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
586581

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

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

0 commit comments

Comments
 (0)