JDevlieghere/dotfiles

minor change to .ycm_extra_conf.py

Closed this issue · 2 comments

Very good idea to define a function in ycm_extra_conf.py to add project's include directory and its subdirectories to compilation flags. But I think the flag variable should be initialized to ["-I" + include_path] instead of [], because we want to track headers not only in subdirectories but also in include_path.

def FlagsForInclude(root):
    try:
        include_path = FindNearest(root, 'include')
        flags = ["-I" + include_path] # flags = []
        for dirroot, dirnames, filenames in os.walk(include_path):
            for dir_path in dirnames:
                real_path = os.path.join(dirroot, dir_path)
                flags = flags + ["-I" + real_path]
        return flags
    except:
        return None

I think you are right, thanks for spotting that! You can make a pull-request or I can update file for you if you want.

Cheers,
Jonas

Because os.walk returns its root too this isn't necessary and we'd just end up with two instances of the same path.