JDevlieghere / dotfiles

⚙ Dotfiles for Linux &macOS
MIT License
293 stars 58 forks source link

minor change to .ycm_extra_conf.py #2

Closed Litchiware closed 6 years ago

Litchiware commented 8 years ago

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
JDevlieghere commented 8 years ago

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

JDevlieghere commented 6 years ago

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