From 534f6f57d46bec70a158564c5be6b40f1cd2bd06 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 4 Oct 2013 10:30:58 -0700 Subject: [PATCH] Fix issue with slow cursor moving in Python This happened when moving the cursor in normal mode. The problem was that we were calling SyntasticCheck on every cursor move because YCM would think that the FileReadyToParse event processing returned diagnostics... but YCM only integrates with Syntastic for C-family files. Fixed by only triggering SyntasticCheck in C-family files. --- autoload/youcompleteme.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index b1554152..48cc8723 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -29,6 +29,14 @@ let s:cursor_moved = 0 let s:moved_vertically_in_insert_mode = 0 let s:previous_num_chars_on_current_line = -1 +let s:forced_syntastic_checker_for = { + \ 'cpp': 1, + \ 'c': 1, + \ 'objc': 1, + \ 'objcpp': 1, + \ } + + function! youcompleteme#Enable() " When vim is in diff mode, don't run if &diff @@ -165,6 +173,12 @@ function! s:ForceSyntasticCFamilyChecker() endfunction +function! s:ForcedAsSyntasticCheckerForCurrentFiletype() + return g:ycm_register_as_syntastic_checker && + \ get( s:forced_syntastic_checker_for, &filetype, 0 ) +endfunction + + function! s:AllowedToCompleteInCurrentFile() if empty( &filetype ) || getbufvar(winbufnr(winnr()), "&buftype") ==# 'nofile' return 0 @@ -411,7 +425,7 @@ endfunction function! s:UpdateDiagnosticNotifications() let should_display_diagnostics = \ get( g:, 'loaded_syntastic_plugin', 0 ) && - \ g:ycm_register_as_syntastic_checker && + \ s:ForcedAsSyntasticCheckerForCurrentFiletype() && \ pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' ) if !should_display_diagnostics