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.
This commit is contained in:
Strahinja Val Markovic 2013-10-04 10:30:58 -07:00
parent afa1afc49b
commit 534f6f57d4

View File

@ -29,6 +29,14 @@ let s:cursor_moved = 0
let s:moved_vertically_in_insert_mode = 0 let s:moved_vertically_in_insert_mode = 0
let s:previous_num_chars_on_current_line = -1 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() function! youcompleteme#Enable()
" When vim is in diff mode, don't run " When vim is in diff mode, don't run
if &diff if &diff
@ -165,6 +173,12 @@ function! s:ForceSyntasticCFamilyChecker()
endfunction endfunction
function! s:ForcedAsSyntasticCheckerForCurrentFiletype()
return g:ycm_register_as_syntastic_checker &&
\ get( s:forced_syntastic_checker_for, &filetype, 0 )
endfunction
function! s:AllowedToCompleteInCurrentFile() function! s:AllowedToCompleteInCurrentFile()
if empty( &filetype ) || getbufvar(winbufnr(winnr()), "&buftype") ==# 'nofile' if empty( &filetype ) || getbufvar(winbufnr(winnr()), "&buftype") ==# 'nofile'
return 0 return 0
@ -411,7 +425,7 @@ endfunction
function! s:UpdateDiagnosticNotifications() function! s:UpdateDiagnosticNotifications()
let should_display_diagnostics = let should_display_diagnostics =
\ get( g:, 'loaded_syntastic_plugin', 0 ) && \ get( g:, 'loaded_syntastic_plugin', 0 ) &&
\ g:ycm_register_as_syntastic_checker && \ s:ForcedAsSyntasticCheckerForCurrentFiletype() &&
\ pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' ) \ pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' )
if !should_display_diagnostics if !should_display_diagnostics