#!/usr/bin/env python

import os
import os.path
import logging
# import fnmatch
# import ycm_core
# import re

__header__ = """

    Credits to https://jonasdevlieghere.com/a-better-youcompleteme-config/

                              -`
              ...            .o+`
           .+++s+   .h`.    `ooo/
          `+++%++  .h+++   `+oooo:
          +++o+++ .hhs++. `+oooooo:
          +s%%so%.hohhoo'  'oooooo+:
          `+ooohs+h+sh++`/:  ++oooo+:
           hh+o+hoso+h+`/++++.+++++++:
            `+h+++h.+ `/++++++++++++++:
                     `/+++ooooooooooooo/`
                    ./ooosssso++osssssso+`
                   .oossssso-````/osssss::`
                  -osssssso.      :ssss``to.
                 :osssssss/  Mike  osssl   +
                /ossssssss/   8a   +sssslb
              `/ossssso+/:-        -:/+ossss'.-
             `+sso+:-`                 `.-/+oso:
            `++:.                           `-/+/
            .`                                 `/
"""


BASE_FLAGS = [
    '-Wall',
    '-Wextra',
    '-Werror',
    '-Wno-long-long',
    '-Wno-variadic-macros',
    '-fexceptions',
    '-ferror-limit=10000',
    '-DNDEBUG',
    '-std=c++11',
    '-xc++',
    '-I/usr/lib/',
    '-I/usr/include/'
]

SOURCE_EXTENSIONS = [
    '.cpp',
    '.cxx',
    '.cc',
    '.c',
    '.m',
    '.mm'
]

SOURCE_DIRECTORIES = [
    'src',
    'lib'
]

HEADER_EXTENSIONS = [
    '.h',
    '.hxx',
    '.hpp',
    '.hh'
]

HEADER_DIRECTORIES = [
    'include'
]

def IsHeaderFile(filename):
    extension = os.path.splitext(filename)[1]
    return extension in HEADER_EXTENSIONS


def FindNearest(path, target, build_folder):
    candidate = os.path.join(path, target)
    if(os.path.isfile(candidate) or os.path.isdir(candidate)):
        logging.info("Found nearest " + target + " at " + candidate)
        return candidate

    parent = os.path.dirname(os.path.abspath(path))
    if(parent == path):
        raise RuntimeError("Could not find " + target)

    if(build_folder):
        candidate = os.path.join(parent, build_folder, target)
        if(os.path.isfile(candidate) or os.path.isdir(candidate)):
            logging.info("Found nearest " + target + " in build folder at " + candidate)
            return candidate

    return FindNearest(parent, target, build_folder)


def FlagsForClangComplete(root):
    try:
        clang_complete_path = FindNearest(root, '.clang_complete')
        clang_complete_flags = open(clang_complete_path, 'r').read().splitlines()

        clang_complete_path = FindNearest(root, '.clang')
        clang_complete_flags += open(clang_complete_path, 'r').read().splitlines()
        return clang_complete_flags
    except:
        return None


def FlagsForInclude(root):
    try:
        include_path = FindNearest(root, 'include')
        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


def FlagsForFile(filename):
    root = os.path.realpath(filename)
    final_flags = BASE_FLAGS
    clang_flags = FlagsForClangComplete(root)
    if clang_flags:
        final_flags = final_flags + clang_flags
    include_flags = FlagsForInclude(root)
    if include_flags:
        final_flags = final_flags + include_flags
    return {
        'flags': final_flags,
        'do_cache': True
    }

@@ -16,16 +16,164 @@
 python%0A%0A
+from __future__ import unicode_literals%0Afrom __future__ import print_function%0Afrom __future__ import with_statement%0Afrom __future__ import division%0A
 import o
@@ -1195,16 +1195,67 @@
 error',%0A
+    '-Weverything',%0A    '-Wno-missing-prototypes',%0A
     '-Wn
@@ -1362,16 +1362,45 @@
 UG',%0A   
+ # '-Wno-c++98-compat',%0A    #
  '-std=c
@@ -1409,16 +1409,18 @@
 11',%0A   
+ #
  '-xc++'
@@ -1421,16 +1421,38 @@
 -xc++',%0A
+%5D%0A%0ALINUX_INCLUDES = %5B%0A
     '-I/
@@ -1483,24 +1483,59 @@
 nclude/'%0A%5D%0A%0A
+WINDOWS_INCLUDES = %5B%0A    # TODO%0A%5D%0A%0A
 SOURCE_EXTEN
@@ -1768,16 +1768,112 @@
 ude'%0A%5D%0A%0A
+if os.name == 'nt':%0A    BASE_FLAGS += WINDOWS_INCLUDES%0Aelse:%0A    BASE_FLAGS += LINUX_INCLUDES%0A%0A%0A
 def IsHe
@@ -2564,16 +2564,41 @@
 target +
+%0A                        
  %22 in bu
@@ -2852,24 +2852,37 @@
 lags = open(
+%0A            
 clang_comple
@@ -3023,32 +3023,69 @@
 g_complete_path,
+%0A                                    
  'r').read().spl

Change compiling flags and separate includes from linux and windows