diff options
-rw-r--r-- | runtime/doc/change.txt | 7 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 13 | ||||
-rw-r--r-- | runtime/doc/news.txt | 6 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 5 | ||||
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 25 |
5 files changed, 52 insertions, 4 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 09db651614..9ff16165d7 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -281,6 +281,13 @@ gr{char} Replace the virtual characters under the cursor with that have a special meaning in Insert mode, such as most CTRL-keys, cannot be used. + *gr-default* + Nvim creates default mappings with "gr" as a prefix, + which may inhibit the behavior of |gr|. Use the + following to restore the builtin behavior: > + nnoremap <nowait> gr gr +< + *digraph-arg* The argument for Normal mode commands like |r| and |t| is a single character. When 'cpo' doesn't contain the 'D' flag, this character can also be entered diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 5729531b30..ba5dd5fbef 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -61,6 +61,16 @@ options are not restored when the LSP client is stopped or detached. - |K| is mapped to |vim.lsp.buf.hover()| unless |'keywordprg'| is customized or a custom keymap for `K` exists. + *grr* *gra* *grn* *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()| +- CTRL-S is mapped in Insert mode to |vim.lsp.buf.signature_help()| + +If not wanted, these keymaps can be removed at any time using +|vim.keymap.del()| or |:unmap| (see also |gr-default|). + *lsp-defaults-disable* To override the above defaults, set or unset the options on |LspAttach|: >lua @@ -80,9 +90,6 @@ Example: >lua vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) - if client.supports_method('textDocument/rename') then - -- Create a keymap for vim.lsp.buf.rename() - end if client.supports_method('textDocument/implementation') then -- Create a keymap for vim.lsp.buf.implementation end diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 03f6f7f8fd..708e127136 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -79,7 +79,11 @@ API DEFAULTS -• TODO +• Keymaps: + - |grn| in Normal mode maps to |vim.lsp.buf.rename()| + - |grr| in Normal mode maps to |vim.lsp.buf.references()| + - |gra| in Normal and Visual mode maps to |vim.lsp.buf.code_action()| + - CTRL-S in Insert mode maps to |vim.lsp.buf.signature_help()| EDITOR diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 15134531e1..5d894bb5e1 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -138,6 +138,11 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y". - * |v_star-default| - gc |gc-default| |v_gc-default| |o_gc-default| - gcc |gcc-default| +- gr prefix |gr-default| + - |grn| + - |grr| + - |gra| +- <C-S> |i_CTRL-S| - ]d |]d-default| - [d |[d-default| - <C-W>d |CTRL-W_d-default| diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 7015d376ae..5b964b84a0 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -149,6 +149,31 @@ do vim.keymap.set({ 'o' }, 'gc', textobject_rhs, { desc = 'Comment textobject' }) end + --- Default maps for LSP functions. + --- + --- These are mapped unconditionally to avoid different behavior depending on whether an LSP + --- 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|, |i_CTRL-S|. + do + vim.keymap.set('n', 'grn', function() + vim.lsp.buf.rename() + end, { desc = 'vim.lsp.buf.rename()' }) + + vim.keymap.set({ 'n', 'x' }, 'gra', function() + vim.lsp.buf.code_action() + end, { desc = 'vim.lsp.buf.code_action()' }) + + vim.keymap.set('n', 'grr', function() + vim.lsp.buf.references() + end, { desc = 'vim.lsp.buf.references()' }) + + vim.keymap.set('i', '<C-S>', function() + vim.lsp.buf.signature_help() + end, { desc = 'vim.lsp.buf.signature_help()' }) + end + --- Map [d and ]d to move to the previous/next diagnostic. Map <C-W>d to open a floating window --- for the diagnostic under the cursor. --- |