I am trying to configure the vim Plugin "YouCompleteMe". My C++ project consists of many header files, which are spread all over the directory tree. In order to add header directories I have to add them in the ".ycm_extra_conf.py".
Excerpt:
'-I',
'./src/base/utils',
'-I',
'./src/base/modules',   
But something like this does not work:
'-I',
'./src/base/*',
Is there a way to tell YCM to recursively search for header files?
Thank you.
I have added a new syntax -ISUB to include all sub-directories. 
e.g.
"-ISUB./Pods/Headers/Public"
full .ycm_extra_conf.py here
import os
import ycm_core
flags = [
#custom definition, include subfolders
'-ISUB./Pods/Headers/Public',
'-I./Pod/Classes',
]
def Subdirectories(directory):
  res = []
  for path, subdirs, files in os.walk(directory):
    for name in subdirs:
      item = os.path.join(path, name)
      res.append(item)
  return res
def IncludeFlagsOfSubdirectory( flags, working_directory ):
  if not working_directory:
    return list( flags )
  new_flags = []
  make_next_include_subdir = False
  path_flags = [ '-ISUB']
  for flag in flags:
    # include the directory of flag as well
    new_flag = [flag.replace('-ISUB', '-I')]
    if make_next_include_subdir:
      make_next_include_subdir = False
      for subdir in Subdirectories(os.path.join(working_directory, flag)):
        new_flag.append('-I')
        new_flag.append(subdir)
    for path_flag in path_flags:
      if flag == path_flag:
        make_next_include_subdir = True
        break
      if flag.startswith( path_flag ):
        path = flag[ len( path_flag ): ]
        for subdir in Subdirectories(os.path.join(working_directory, path)):
            new_flag.append('-I' + subdir)
        break
    new_flags =new_flags + new_flag
  return new_flags
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With