diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 277f5ed3..97d4f0c9 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -60,7 +60,10 @@ function! youcompleteme#Enable() exe 'python sys.path = sys.path + ["' . s:script_folder_path . '/../python"]' py import ycm py identcomp = ycm.IdentifierCompleter() - py clangcomp = ycm.ClangCompleter() + + if g:ycm_clang_completion_enabled + py clangcomp = ycm.ClangCompleter() + endif " Calling this once solves the problem of BufRead/BufEnter not triggering for " the first loaded file. This should be the last command executed in this diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index e4d8f324..52445107 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -29,6 +29,9 @@ let g:loaded_youcompleteme = 1 let s:save_cpo = &cpo set cpo&vim +let g:ycm_clang_completion_enabled = + \ get(g:, 'ycm_clang_completion_enabled', 1) + " On-demand loading. Let's use the autoload folder and not slow down vim's " startup procedure. augroup youcompletemeStart diff --git a/python/ycm.py b/python/ycm.py index 23a6a56e..78010da9 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -22,6 +22,7 @@ import vim import indexer MIN_NUM_CHARS = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) ) +CLANG_COMPLETION_ENABLED = int( vim.eval( "g:ycm_clang_completion_enabled" ) ) CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] ) MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10 @@ -211,6 +212,9 @@ def CurrentLineAndColumn(): def ShouldUseClang( start_column ): + if not CLANG_COMPLETION_ENABLED: + return False + filetype = vim.eval( "&filetype" ) if filetype not in CLANG_FILETYPES: return False @@ -332,4 +336,3 @@ def RemoveIdentFreeText( text ): re.DOTALL | re.MULTILINE ) return re.sub( pattern, replacer, text ) -