Преглед изворни кода

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

Fixes #256.
Strahinja Val Markovic пре 12 година
родитељ
комит
6d0c736d04
2 измењених фајлова са 13 додато и 6 уклоњено
  1. 5 4
      README.md
  2. 8 2
      autoload/youcompleteme.vim

+ 5 - 4
README.md

@@ -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.
 

+ 8 - 2
autoload/youcompleteme.vim

@@ -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 )