Skip to content

Instantly share code, notes, and snippets.

@matthiasvegh
Last active August 29, 2015 14:14
Show Gist options
  • Save matthiasvegh/396986e9c81708dfcbb2 to your computer and use it in GitHub Desktop.
Save matthiasvegh/396986e9c81708dfcbb2 to your computer and use it in GitHub Desktop.
Script to retrieve compilation flags according to YouCompleteMe.
#!/usr/bin/env python
import sys
import os
ycmpath = os.path.expanduser("~/.vim/bundle/YouCompleteMe")
def main():
sys.path.insert(0, os.path.join(ycmpath, 'third_party/ycmd'))
sys.path.insert(0, os.path.join(ycmpath, 'third_party/ycmd/third_party/frozendict'))
import ycmd.completers.cpp.flags
import ycmd.user_options_store
ycmd.user_options_store.SetAll({'global_ycm_extra_conf': os.path.expanduser('~/.ycm_extra_conf.py'), 'confirm_extra_conf':False})
flagsObject = ycmd.completers.cpp.flags.Flags()
result = flagsObject.FlagsForFile(sys.argv[1])
output = ""
for i in range(len(result)):
output += " "+result[i]
print output
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment