Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change LSP Keybindings to Match the Default gr Bindings Introduced in Neovim 0.11 #1427

Merged
merged 2 commits into from
Apr 9, 2025

Conversation

theopn
Copy link
Contributor

@theopn theopn commented Mar 29, 2025

                                          *grr* *gra* *grn* *gri* *i_CTRL-S*
Some keymaps are created unconditionally when Nvim starts:
- "grn" is mapped in Normal mode to |vim.lsp.buf.rename()|
- "gra" is mapped in Normal and Visual mode to |vim.lsp.buf.code_action()|
- "grr" is mapped in Normal mode to |vim.lsp.buf.references()|
- "gri" is mapped in Normal mode to |vim.lsp.buf.implementation()|
- "gO" is mapped in Normal mode to |vim.lsp.buf.document_symbol()|
- CTRL-S is mapped in Insert mode to |vim.lsp.buf.signature_help()|

Neovim 0.11 introduced many default LSP keybindings prefixed with gr, and this PR changes the Telescope keybindings defined in LspAttach autocmds to match the default ones.

I think changing other keybindings (<leader>D for type definition and <leader>ws for workspace symbols) to have g prefix should also be considered.

@arerossehaug
Copy link

Any reason to choose gca over gra for code actions?
While the [G]oto [C]ode [A]ction makes more sense than [G]oto [R]? [A]ction, the gra is a smoother key combination in my opinion

Semi related, but should it be considered that gd (goto definition) should become grd?

@theopn
Copy link
Contributor Author

theopn commented Mar 31, 2025

@arerossehaug 😅 just a typo, I amended it to be gra. My idea was to follow the default keybindings provided by Neovim to minimize the confusion.

I have also added a commit for changing the other keybindings, prefixing gr for "Goto" and g for opening a list of symbols:

  • gd -> grd for goto definition
  • gD -> grD for goto declaration
  • <leader>D -> grt for type definition
  • <leader>w -> gW for workspace symbols

@feoh
Copy link
Collaborator

feoh commented Apr 9, 2025

I have no feelings about this, but making changes to key bindings always ends up with a million angry WHY DID YOU MOVE MY CHEESE? comments.

Thoughts from everyone?

@theopn
Copy link
Contributor Author

theopn commented Apr 9, 2025

@feoh I agree that changing keybindings can cause confusion, but I have two arguments for this particular changes:

  1. some existing keybindings (e.g., gr for LSP references) conflicts with the new default keybindings in 0.11, so we need to either delete the default keybindings or change our keybindings; see [Suggestion] default lsp key mappings in neovim v0.11.0 will interfere existing key mappings in lspconfig #1436
  2. these are the default keybindings that Neovim will use moving forward, and considering the demographics of people using Kickstart (lots of beginners and new to configuring Neovim) and how they use Kickstart (use to build their own config), I think it is important to let them know that default keybindings for such and such actions exist.

Thoughts?

@chrstief
Copy link

chrstief commented Apr 9, 2025

If the kickstart project was started today, they would go with the default nvim keybinds. I’m in support of this change, instead of sticking to non default keybinds for historic reasons.

@feoh
Copy link
Collaborator

feoh commented Apr 9, 2025

Two people voting yay is enough for me :) Thanks all! merging.

@feoh feoh merged commit 1a5787b into nvim-lua:master Apr 9, 2025
1 check passed
dribic pushed a commit to dribic/nvim-files that referenced this pull request Apr 9, 2025
…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
fluxth added a commit to fluxth/nvim-config that referenced this pull request Apr 10, 2025
…roduced in Neovim 0.11 (nvim-lua#1427)"

This reverts commit 1a5787b.

I'm not in the mood to learn new keybindings right now.
Will do it in my own time.
fluxth added a commit to fluxth/nvim-config that referenced this pull request Apr 10, 2025
…roduced in Neovim 0.11 (nvim-lua#1427)"

This reverts commit 1a5787b.

I'm not in the mood to learn new keybindings right now.
Will do it in my own time.
dimitrov-anasoft pushed a commit to dimitrov-anasoft/kickstart.nvim that referenced this pull request Apr 10, 2025
…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
@5brian
Copy link

5brian commented Apr 11, 2025

Sorry to necro this, would a pr to add the few leader key bindings back in comments be accepted?

For example:


-- If you prefer the legacy <leader> keymaps,
-- you can uncomment the following lines

faizfrhn added a commit to faizfrhn/kickstart.nvim that referenced this pull request Apr 11, 2025
* Change LSP Keybindings to Match the Default gr Bindings Introduced in Neovim 0.11 (nvim-lua#1427)
* Remove Telescope 0.1 branch lock (nvim-lua#1448)
vencronys pushed a commit to vencronys/kickstart.nvim that referenced this pull request Apr 12, 2025
…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
dazemc pushed a commit to dazemc/kickstart.nvim that referenced this pull request Apr 12, 2025
…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
DerFrZocker pushed a commit to DerFrZocker/.dotfiles-nvim that referenced this pull request Apr 12, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants