Making sure that <C-Space> works in console Vim

Fixes #256.
This commit is contained in:
Strahinja Val Markovic 2013-04-19 18:33:06 -07:00
parent 93ed6f7db7
commit 6d0c736d04
2 changed files with 13 additions and 6 deletions

View File

@ -782,10 +782,11 @@ after typing `.`, `->` and `::` in insert mode (if semantic completion support
has been compiled in). This key mapping can be used to trigger semantic
completion anywhere. Useful for searching for top-level functions and classes.
Note that the default of `<C-Space>` means Ctrl-Space. Also note that the
default mapping will probably only work in GUI Vim (Gvim or MacVim) and not in
plain console Vim because the terminal usually does not forward modifier key
combinations to Vim.
Console Vim (not Gvim or MacVim) passes `<Nul>` to Vim when the user types
`<C-Space>` so YCM will make sure that `<Nul>` is used in the map command when
you're editing in console Vim, and `<C-Space>` in GUI Vim. This means that you
can just press `<C-Space>` in both console and GUI Vim and YCM will do the right
thing.
Setting this option to an empty string will make sure no mapping is created.

View File

@ -119,10 +119,16 @@ function! s:SetUpKeyMappings()
endfor
if !empty( g:ycm_key_invoke_completion )
let invoke_key = g:ycm_key_invoke_completion
" Inside the console, <C-Space> is passed as <Nul> to Vim
if invoke_key ==# '<C-Space>' && !has('gui_running')
let invoke_key = '<Nul>'
endif
" <c-x><c-o> trigger omni completion, <c-p> deselects the first completion
" candidate that vim selects by default
silent! exe 'inoremap <unique> ' . g:ycm_key_invoke_completion .
\ ' <C-X><C-O><C-P>'
silent! exe 'inoremap <unique> ' . invoke_key . ' <C-X><C-O><C-P>'
endif
if !empty( g:ycm_key_detailed_diagnostics )