From 5d06eade2599ccf378b284eb7aeec38c0256ec9e Mon Sep 17 00:00:00 2001 From: Caleb White Date: Thu, 26 Jun 2025 08:24:13 -0500 Subject: [PATCH] feat(defaults): map "grt" to LSP type_definition #34642 --- runtime/doc/lsp.txt | 3 ++- runtime/doc/news.txt | 2 ++ runtime/doc/vim_diff.txt | 1 + runtime/lua/vim/_defaults.lua | 6 +++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index bc1f740da28..6e106251ee7 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -81,12 +81,13 @@ 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 - *grr* *gra* *grn* *gri* *i_CTRL-S* *an* *in* + *grr* *gra* *grn* *gri* *grt* *i_CTRL-S* *an* *in* These GLOBAL 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()| +- "grt" is mapped in Normal mode to |vim.lsp.buf.type_definition()| - "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()| - "an" and "in" are mapped in Visual mode to outer and inner incremental diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index d85d59463c8..6aea9031c73 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -139,6 +139,8 @@ DEFAULTS was implemented as an internal C routine). • Project-local configuration ('exrc') is also loaded from parent directories. Unset 'exrc' to stop further search. +• Mappings: + • |grt| in Normal mode maps to |vim.lsp.buf.type_definition()| DIAGNOSTICS diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7d81f3894f4..b9aae0b9f82 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -154,6 +154,7 @@ you never want any default mappings, call |:mapclear| early in your config. - |grr| - |gra| - |gri| + - |grt| - |gO| - |i_CTRL-S| - ]d |]d-default| diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 496e49b340a..a51b08ed7ac 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -191,7 +191,7 @@ do --- client is attached. If no client is attached, or if a server does not support a capability, an --- error message is displayed rather than exhibiting different behavior. --- - --- See |grr|, |grn|, |gra|, |gri|, |gO|, |i_CTRL-S|. + --- See |grr|, |grn|, |gra|, |gri|, |grt| |gO|, |i_CTRL-S|. do vim.keymap.set('n', 'grn', function() vim.lsp.buf.rename() @@ -209,6 +209,10 @@ do vim.lsp.buf.implementation() end, { desc = 'vim.lsp.buf.implementation()' }) + vim.keymap.set('n', 'grt', function() + vim.lsp.buf.type_definition() + end, { desc = 'vim.lsp.buf.type_definition()' }) + vim.keymap.set('x', 'an', function() vim.lsp.buf.selection_range(vim.v.count1) end, { desc = 'vim.lsp.buf.selection_range(vim.v.count1)' })