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