.ycm_extra_conf.py 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/python -Es
# vim: et:ts=4:sw=4:colorcolumn=100
#
# Configuration for You Complete Me (YCM) code-completion engine for Vim.
#
# This file is released into the public domain.
#

import sys
import os

DIR = os.path.dirname(__file__)

FLAGS = [
    '-std=gnu99',
16
    '-Wall', '-Wno-unused', '-Werror=implicit', '-Wno-#warnings',
17
    '-DCONFIG_DIR=', '-DRUN_DIR=', '-DSTORAGE_DIR=', '-DPACKAGE_VERSION=',
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
]

CONFIG_H = 'src/config.h'

INCLUDES = [
]

def relative_path(filename):
    return os.path.relpath(filename, DIR)

def absolute_path(filename):
    return os.path.normpath(os.path.join(DIR, filename))

def includes_for(filename):
    relative = relative_path(filename)
    for prefix, includes in INCLUDES:
        if relative.startswith(prefix + '/'):
            return [prefix] + includes
    return []

def include_flag(path):
    return "-I%s" % absolute_path(path)

def FlagsForFile(filename):
    # input filename is an absolute path
    config = ["-include", absolute_path(CONFIG_H)]
    includes = [include_flag(f) for f in includes_for(filename)]
    return {'flags': FLAGS + config + includes, 'do_cache': True}

if __name__ == '__main__':
    print >>sys.stderr, "Not runnable."
    sys.exit(1)