Skip to content

Commit

Permalink
Update YCM config to work with header-onlies of the lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu343726 committed Jul 13, 2018
1 parent fb82fca commit d99f082
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .ycm_extra_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,23 @@ def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]

def ReplacementFile( headerfile, source_extension ):
def SrcFromHeader(headerfile, source_extension):
file_path, file_name = os.path.split(headerfile)
name, _ = os.path.splitext(file_name)
relative_path = os.path.relpath(file_path, INCLUDE_DIR)
return os.path.join(SRC_DIR, relative_path, name + source_extension)

def FindAnySrcFile():
return os.path.join(SRC_DIR, "utils", "demangle.cpp")

def ReplacementFile( headerfile, source_extension ):
src_from_header = SrcFromHeader(headerfile, source_extension)

if os.path.isfile(src_from_header):
return src_from_header
else:
return FindAnySrcFile()

def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
Expand Down

0 comments on commit d99f082

Please sign in to comment.