From 52b21ae20f81e94aa920f191d762d575f721ba0b Mon Sep 17 00:00:00 2001 From: Jan Vcelak <jan.vcelak@nic.cz> Date: Tue, 7 Apr 2015 16:10:25 +0200 Subject: [PATCH] add config for YCM completion engine --- .gitignore | 1 + .ycm_extra_conf.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .ycm_extra_conf.py diff --git a/.gitignore b/.gitignore index dd362beafa..4e25d8881b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.orig *.lo *.rej +*.pyc .libs/ .deps/ .dirstamp diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py new file mode 100644 index 0000000000..a250f692c6 --- /dev/null +++ b/.ycm_extra_conf.py @@ -0,0 +1,51 @@ +#!/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', + '-Wall', '-Wno-unused', '-Werror=implicit', + '-DCONFIG_DIR=', '-DRUN_DIR=', '-DSTORAGE_DIR=', +] + +CONFIG_H = 'src/config.h' + +INCLUDES = [ + ('src', []), + ('tests', ['src', 'libtap']), +] + +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) -- GitLab