From 15561b9f1eb92a7cde2c8d683d002aed013607f5 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 5 Aug 2012 19:55:06 -0700 Subject: [PATCH] Adding 'preview' to completeopt if not forbidden The user can opt-out of this, but we set it by default since most people don't know that the option exists. Those that are annoyed by it can just toggle an option in their vimrc. --- autoload/youcompleteme.vim | 12 ++++++++---- plugin/youcompleteme.vim | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 4d6f7440..f7424fd0 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -38,10 +38,6 @@ function! youcompleteme#Enable() return endif - if g:ycm_allow_changing_updatetime - set ut=2000 - endif - augroup youcompleteme autocmd! autocmd CursorMovedI * call s:OnCursorMovedInsertMode() @@ -68,6 +64,14 @@ function! youcompleteme#Enable() " Also, having this option set breaks the plugin. set completeopt-=longest + if g:ycm_add_preview_to_completeopt + set completeopt+=preview + endif + + if g:ycm_allow_changing_updatetime + set ut=2000 + endif + " With this command, when the completion window is visible, the tab key will " select the next candidate in the window. In vim, this also changes the " typed-in text to that of the candidate completion. diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index b73dd316..33eeb922 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -37,12 +37,16 @@ let g:ycm_min_num_of_chars_for_completion = let g:ycm_filetypes_to_ignore = \ get( g:, 'ycm_filetypes_to_ignore', { 'notes' : 1 } ) +" TODO: make this more granular let g:ycm_filetype_completion_enabled = \ get( g:, 'ycm_filetype_completion_enabled', 1 ) let g:ycm_allow_changing_updatetime = \ get( g:, 'ycm_allow_changing_updatetime', 1 ) +let g:ycm_add_preview_to_completeopt = + \ get( g:, 'ycm_add_preview_to_completeopt', 1 ) + " This is basic vim plugin boilerplate let s:save_cpo = &cpo