Skip to content

Instantly share code, notes, and snippets.

@hustlijian
Created February 28, 2020 07:18
Show Gist options
  • Save hustlijian/74d4ceabb196098b09b1e499fca6e597 to your computer and use it in GitHub Desktop.
Save hustlijian/74d4ceabb196098b09b1e499fca6e597 to your computer and use it in GitHub Desktop.
YCM config to FindCorrespondingSourceFile from upper directory (eg:libevent)
def FindCorrespondingSourceFile( filename ):
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
return replacement_file
name = os.path.basename(replacement_file)
upper_file = os.path.normpath(os.path.join(os.path.dirname(replacement_file), "../", name))
if os.path.exists( upper_file):
return upper_file
upper_file = os.path.normpath(os.path.join(os.path.dirname(replacement_file), "../../", name))
if os.path.exists( upper_file):
return upper_file
return filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment