feat(defaults): map "grx" to vim.lsp.codelens.run() #37689

Problem
Unlike inlay hints, code lenses are closely related to running commands;
a significant number of code lenses are used to execute a command (such
as running tests). Therefore, it is necessary to provide a default
mapping for them.

Solution
Add a new default mapping "grx" (mnemonic: "eXecute", like "gx").
This commit is contained in:
Yi Ming
2026-03-20 01:47:52 +08:00
committed by GitHub
parent e7684fb642
commit 06befe1e34
4 changed files with 8 additions and 2 deletions

View File

@@ -74,7 +74,7 @@ functionality and (2) the options are empty or were set by the builtin runtime
(ftplugin) files. The options are not restored when the LSP client is stopped
or detached.
GLOBAL DEFAULTS *gra* *gri* *grn* *grr* *grt* *i_CTRL-S*
GLOBAL DEFAULTS *gra* *gri* *grn* *grr* *grt* *grx* *i_CTRL-S*
These GLOBAL keymaps are created unconditionally when Nvim starts:
@@ -83,6 +83,7 @@ These GLOBAL keymaps are created unconditionally when Nvim starts:
- "grn" is mapped to |vim.lsp.buf.rename()|
- "grr" is mapped to |vim.lsp.buf.references()|
- "grt" is mapped to |vim.lsp.buf.type_definition()|
- "grx" is mapped to |vim.lsp.codelens.run()|
- "gO" is mapped to |vim.lsp.buf.document_symbol()|
- CTRL-S (Insert mode) is mapped to |vim.lsp.buf.signature_help()|
- |v_an| and |v_in| fall back to LSP |vim.lsp.buf.selection_range()| if

View File

@@ -199,6 +199,7 @@ DEFAULTS
Unset 'exrc' to stop further search.
• Mappings:
• |grt| in Normal mode maps to |vim.lsp.buf.type_definition()|
• |grx| in Normal mode maps to |vim.lsp.codelens.run()|
• 'shada' default now excludes "/tmp/" and "/private/" paths to reduce clutter in |:oldfiles|.
• Enabled treesitter highlighting for Markdown files

View File

@@ -209,6 +209,10 @@ do
vim.lsp.buf.code_action()
end, { desc = 'vim.lsp.buf.code_action()' })
vim.keymap.set('n', 'grx', function()
vim.lsp.codelens.run()
end, { desc = 'vim.lsp.codelens.run()' })
vim.keymap.set('n', 'grr', function()
vim.lsp.buf.references()
end, { desc = 'vim.lsp.buf.references()' })

View File

@@ -273,7 +273,7 @@ describe(':help', function()
n.command(':help lsp')
n.feed('gg/codelens.run()|<cr>')
eq({ '|vim.lsp.codelens.run()|.', 'lsp.txt' }, buf_word())
eq({ '|vim.lsp.codelens.run()|', 'lsp.txt' }, buf_word())
-- ^ cursor on "codelens"
n.command(':help!')
eq({ '*vim.lsp.codelens.run()*', 'lsp.txt' }, buf_word())