vim: fix the stupid Ctrl-I

https://vi.stackexchange.com/questions/39717/mapping-to-ctrlm-and-ctrli-in-neovim

Also nmap K into jumping to definition. Use Ctrl-O/I to jump around the jumplist.
This commit is contained in:
2025-06-20 18:32:31 +08:00
parent 4334813891
commit 5ffcb2c3a0

15
vimrc
View File

@ -192,9 +192,7 @@ autocmd FileType c,cpp,go,rust,typescript inoremap <buffer> <C-]> {}<Left>
autocmd FileType vim,tex,python inoremap <buffer> { {}<Left>
autocmd FileType vim,tex,python inoremap <buffer> <C-]> <End>{<CR>}<Up><End><CR>
autocmd Filetype go,rust,python,typescript map <buffer><silent><expr> K CocAction("jumpDefinition")
autocmd FileType c,cpp map <buffer><silent><expr> K CocAction("jumpDeclaration")
autocmd FileType c,cpp map <buffer><silent><expr> <C-K> CocAction("jumpDefinition")
autocmd Filetype c,cpp,go,rust,python,typescript nmap <buffer><silent> K <Plug>(coc-definition)
augroup END
@ -216,9 +214,18 @@ else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Guess what? Despite Neovim being smart enough to distinguish
" <Ctrl-I> from <Tab>, it treats <Ctrl-I> as <Tab> anyways if
" you have a normal mode mapping for <Tab>. Screw me I guess.
"
" https://vi.stackexchange.com/a/46704
" https://github.com/neovim/neovim/pull/17932
"
" This magical line tricks Nvim into being smart again.
nnoremap <C-I> <C-I>
" Press Meta-I to invoke hover
nmap <silent> <Tab> :call CocAction('doHover')<CR>
"nmap <silent><expr> <C-I> CocAction('doHover')
" Use tab for trigger completion / cycle snippet replaces.
inoremap <silent><expr> <TAB>