mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	feat(defaults): visual CTRL-R for LSP mappings #28537
Problem: The new LSP "refactor menu" keybinding "crr" is also defined in visual mode, which overlaps with the builtin "c". Solution: Use CTRL-R instead of "crr" for visual mode. fix #28528
This commit is contained in:
		@@ -499,7 +499,7 @@ Lua module: vim.diagnostic                                    *diagnostic-api*
 | 
			
		||||
                          diagnostic instead of prepending it. Overrides the
 | 
			
		||||
                          setting from |vim.diagnostic.config()|.
 | 
			
		||||
      • {focus_id}?       (`string`)
 | 
			
		||||
      • {border}?         (`string`) see |vim.api.nvim_open_win()|.
 | 
			
		||||
      • {border}?         (`string`) see |nvim_open_win()|.
 | 
			
		||||
 | 
			
		||||
*vim.diagnostic.Opts.Signs*
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -61,10 +61,12 @@ 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.
 | 
			
		||||
 | 
			
		||||
                                                  *crr* *v_crr* *crn* *i_CTRL-S*
 | 
			
		||||
                 *crr* *v_crr* *crn* *i_CTRL-S* *v_CTRL-R_CTRL-R* *v_CTRL-R_r*
 | 
			
		||||
Some keymaps are created unconditionally when Nvim starts:
 | 
			
		||||
- "crn" is mapped in Normal mode to |vim.lsp.buf.rename()|
 | 
			
		||||
- "crr" is mapped in Normal and Visual mode to |vim.lsp.buf.code_action()|
 | 
			
		||||
- "crr" is mapped in Normal mode to |vim.lsp.buf.code_action()|
 | 
			
		||||
- CTRL-R CTRL-R (also "CTRL-R r") is mapped in Visual mode to
 | 
			
		||||
  |vim.lsp.buf.code_action()|
 | 
			
		||||
- "gr" is mapped in Normal mode to |vim.lsp.buf.references()| |gr-default|
 | 
			
		||||
- CTRL-S is mapped in Insert mode to |vim.lsp.buf.signature_help()|
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -410,7 +410,8 @@ The following changes to existing APIs or features add new behavior.
 | 
			
		||||
  • 'grepprg' uses the -H and -I flags for grep by default,
 | 
			
		||||
    and defaults to using ripgrep if available.
 | 
			
		||||
  • |crn| in Normal mode maps to |vim.lsp.buf.rename()|.
 | 
			
		||||
  • |crr| in Normal and Visual mode maps to |vim.lsp.buf.code_action()|.
 | 
			
		||||
  • |crr| in Normal mode maps to |vim.lsp.buf.code_action()|.
 | 
			
		||||
  • |v_CTRL-R_CTRL-R| in Visual mode maps to |vim.lsp.buf.code_action()|.
 | 
			
		||||
  • "gr" in Normal mode maps to |vim.lsp.buf.references()| |gr-default|
 | 
			
		||||
  • |i_CTRL-S| in Insert mode maps to |vim.lsp.buf.signature_help()|
 | 
			
		||||
  • "]d" and "[d" in Normal mode map to |vim.diagnostic.goto_next()| and
 | 
			
		||||
 
 | 
			
		||||
@@ -140,6 +140,8 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y".
 | 
			
		||||
- gcc |gcc-default|
 | 
			
		||||
- |crn|
 | 
			
		||||
- |crr|
 | 
			
		||||
- <C-R><C-R> |v_CTRL-R_CTRL-R|
 | 
			
		||||
- <C-R>r |v_CTRL-R_r|
 | 
			
		||||
- gr |gr-default|
 | 
			
		||||
- <C-S> |i_CTRL-S|
 | 
			
		||||
- ]d |]d-default|
 | 
			
		||||
 
 | 
			
		||||
@@ -159,9 +159,14 @@ do
 | 
			
		||||
      vim.lsp.buf.rename()
 | 
			
		||||
    end, { desc = 'vim.lsp.buf.rename()' })
 | 
			
		||||
 | 
			
		||||
    vim.keymap.set({ 'n', 'v' }, 'crr', function()
 | 
			
		||||
      vim.lsp.buf.code_action()
 | 
			
		||||
    end, { desc = 'vim.lsp.buf.code_action()' })
 | 
			
		||||
    local function map_codeaction(mode, lhs)
 | 
			
		||||
      vim.keymap.set(mode, lhs, function()
 | 
			
		||||
        vim.lsp.buf.code_action()
 | 
			
		||||
      end, { desc = 'vim.lsp.buf.code_action()' })
 | 
			
		||||
    end
 | 
			
		||||
    map_codeaction('n', 'crr')
 | 
			
		||||
    map_codeaction('x', '<C-R>r')
 | 
			
		||||
    map_codeaction('x', '<C-R><C-R>')
 | 
			
		||||
 | 
			
		||||
    vim.keymap.set('n', 'gr', function()
 | 
			
		||||
      vim.lsp.buf.references()
 | 
			
		||||
 
 | 
			
		||||
@@ -153,7 +153,7 @@ local M = {}
 | 
			
		||||
---
 | 
			
		||||
--- @field focus_id? string
 | 
			
		||||
---
 | 
			
		||||
--- @field border? string see |vim.api.nvim_open_win()|.
 | 
			
		||||
--- @field border? string see |nvim_open_win()|.
 | 
			
		||||
 | 
			
		||||
--- @class vim.diagnostic.Opts.Underline
 | 
			
		||||
---
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user