From 38f571db1f4c9eaac263c3b7544f2f34eba0c046 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Tue, 29 Oct 2013 13:00:36 -0700 Subject: [PATCH] C-family filetypes now Syntastic passive mode This is needed so that Syntastic doesn't call :SyntasticCheck (and thus YCM code) on file save unnecessarily. We call :SyntasticCheck ourselves often enough. --- autoload/youcompleteme.vim | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 61bf011b..53c8dd30 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -71,10 +71,7 @@ function! youcompleteme#Enable() call s:SetUpKeyMappings() if g:ycm_register_as_syntastic_checker - call s:ForceSyntasticCFamilyChecker() - " We set this to work around segfaults in old versions of Vim - " See here for details: https://github.com/scrooloose/syntastic/issues/834 - let g:syntastic_delayed_redraws = 1 + call s:TweakSyntasticOptions() endif if g:ycm_allow_changing_updatetime @@ -176,8 +173,18 @@ function! s:SetUpBackwardsCompatibility() endfunction +function! s:TweakSyntasticOptions() + call s:ForceCFamilyFiletypesSyntasticPassiveMode() + call s:ForceSyntasticCFamilyChecker() + + " We set this to work around segfaults in old versions of Vim + " See here for details: https://github.com/scrooloose/syntastic/issues/834 + let g:syntastic_delayed_redraws = 1 +endfunction + + +" Needed so that YCM is used as the syntastic checker function! s:ForceSyntasticCFamilyChecker() - " Needed so that YCM is used as the syntastic checker let g:syntastic_cpp_checkers = ['ycm'] let g:syntastic_c_checkers = ['ycm'] let g:syntastic_objc_checkers = ['ycm'] @@ -185,6 +192,16 @@ function! s:ForceSyntasticCFamilyChecker() endfunction +" Needed so that Syntastic doesn't call :SyntasticCheck (and thus YCM code) on +" file save unnecessarily. We call :SyntasticCheck ourselves often enough. +function! s:ForceCFamilyFiletypesSyntasticPassiveMode() + let mode_map = get( g:, 'syntastic_mode_map', {} ) + let mode_map.passive_filetypes = get( mode_map, 'passive_filetypes', [] ) + + \ ['cpp', 'c', 'objc', 'objcpp'] + let g:syntastic_mode_map = mode_map +endfunction + + function! s:ForcedAsSyntasticCheckerForCurrentFiletype() return g:ycm_register_as_syntastic_checker && \ get( s:forced_syntastic_checker_for, &filetype, 0 )