Skip to content

Instantly share code, notes, and snippets.

@tsto
Created February 5, 2013 22:36
Show Gist options
  • Save tsto/4718358 to your computer and use it in GitHub Desktop.
Save tsto/4718358 to your computer and use it in GitHub Desktop.
Straw-man patch for reading .syntastic_c_config.
--- ~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py 2013-02-06 07:56:11.531992253 +1030
+++ .ycm_extra_conf.py 2013-02-06 09:01:34.144999271 +1030
@@ -11,50 +11,57 @@
# These are the compilation flags that will be used in case there's no
# compilation database set.
-flags = [
-'-Wall',
-'-Wextra',
-'-Werror',
-'-Wc++98-compat',
-'-Wno-long-long',
-'-Wno-variadic-macros',
-'-fexceptions',
-'-DNDEBUG',
-'-DUSE_CLANG_COMPLETER',
-# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
-# language to use when compiling headers. So it will guess. Badly. So C++
-# headers will be compiled as C headers. You don't want that so ALWAYS specify
-# a "-std=<something>".
-# For a C project, you would set this to something like 'c99' instead of
-# 'c++11'.
-'-std=c++11',
-# ...and the same thing goes for the magic -x option which specifies the
-# language that the files to be compiled are written in. This is mostly
-# relevant for c++ headers.
-# For a C project, you would set this to 'c' instead of 'c++'.
-'-x',
-'c++',
-'-isystem',
-'../BoostParts',
-'-isystem',
-# This path will only work on OS X, but extra paths that don't exist are not
-# harmful
-'/System/Library/Frameworks/Python.framework/Headers',
-'-isystem',
-'../llvm/include',
-'-isystem',
-'../llvm/tools/clang/include',
-'-I',
-'.',
-'-isystem',
-'./tests/gmock/gtest',
-'-isystem',
-'./tests/gmock/gtest/include',
-'-isystem',
-'./tests/gmock',
-'-isystem',
-'./tests/gmock/include'
-]
+flags = []
+try:
+ file = open(".syntastic_c_config")
+ for line in file:
+ flags.append(line.strip())
+ file.close()
+except:
+ flags = [
+ '-Wall',
+ '-Wextra',
+ '-Werror',
+ '-Wc++98-compat',
+ '-Wno-long-long',
+ '-Wno-variadic-macros',
+ '-fexceptions',
+ '-DNDEBUG',
+ '-DUSE_CLANG_COMPLETER',
+ # THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
+ # language to use when compiling headers. So it will guess. Badly. So C++
+ # headers will be compiled as C headers. You don't want that so ALWAYS specify
+ # a "-std=<something>".
+ # For a C project, you would set this to something like 'c99' instead of
+ # 'c++11'.
+ '-std=c++11',
+ # ...and the same thing goes for the magic -x option which specifies the
+ # language that the files to be compiled are written in. This is mostly
+ # relevant for c++ headers.
+ # For a C project, you would set this to 'c' instead of 'c++'.
+ '-x',
+ 'c++',
+ '-isystem',
+ '../BoostParts',
+ '-isystem',
+ # This path will only work on OS X, but extra paths that don't exist are not
+ # harmful
+ '/System/Library/Frameworks/Python.framework/Headers',
+ '-isystem',
+ '../llvm/include',
+ '-isystem',
+ '../llvm/tools/clang/include',
+ '-I',
+ '.',
+ '-isystem',
+ './tests/gmock/gtest',
+ '-isystem',
+ './tests/gmock/gtest/include',
+ '-isystem',
+ './tests/gmock',
+ '-isystem',
+ './tests/gmock/include'
+ ]
if compilation_database_folder:
database = ycm_core.CompilationDatabase( compilation_database_folder )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment