text: from distutils.sysconfig import get_python_inc
  import platform
  import os
  import subprocess
  import ycm_core
  
  DIR_OF_THIS_SCRIPT = os.path.abspath( os.path.dirname( __file__ ) )
  SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
  
  flags = [
      '-Weverything',
      '-Wno-unused-parameter',
      '-Wno-unused-function',
      '-Wno-unused-variable',
      '-Wno-format-nonliteral',
      '-Wno-padded',
      '-std=c99',
      '-x','c',
      '-I','.'
  ]
  
  
  
  # Set this to the absolute path to the folder (NOT the file!) containing the
  # compile_commands.json file to use that instead of 'flags'. See here for
  # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
  #
  # You can get CMake to generate this file for you by adding:
  #   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
  # to your CMakeLists.txt file.
  #
  # Most projects will NOT need to set this to anything; you can just change the
  # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
  
  #compilation_database_folder = ''
  
  #if os.path.exists( compilation_database_folder ):
  #  database = ycm_core.CompilationDatabase( compilation_database_folder )
  #else:
  database = None
  
  
  def IsHeaderFile( filename ):
    extension = os.path.splitext( filename )[ 1 ]
    return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
  
  
  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
    return filename
  
  
  def Settings( **kwargs ):
    if kwargs[ 'language' ] == 'cfamily':
      # If the file is a header, try to find the corresponding source file and
      # retrieve its flags from the compilation database if using one. This is
      # necessary since compilation databases don't have entries for header files.
      # In addition, use this source file as the translation unit. This makes it
      # possible to jump from a declaration in the header file to its definition
      # in the corresponding source file.
      filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] )
  
      if not database:
        return {
          'flags': flags,
          'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
          'override_filename': filename
        }
  
      compilation_info = database.GetCompilationInfoForFile( filename )
      if not compilation_info.compiler_flags_:
        return {}
  
      # Bear in mind that compilation_info.compiler_flags_ does NOT return a
      # python list, but a "list-like" StringVec object.
      final_flags = list( compilation_info.compiler_flags_ )
  
      return {
        'flags': final_flags,
        'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
        'override_filename': filename
      }
    return {}
  