Added ycm_extra_conf.py

This commit is contained in:
Thomas FORGIONE 2016-10-15 12:30:58 +02:00
parent c3b661e730
commit 52c9e0bc04
3 changed files with 215 additions and 5 deletions

View File

@ -4,11 +4,22 @@ DIRNAME=`dirname $0`
# make-link source target # make-link source target
function make_link { function make_link {
rm -rf $HOME/$2 && ln -s $PWD/$DIRNAME/$1 $HOME/$2 rm -rf $HOME/$2 && ln -s $PWD/$DIRNAME/$1 $HOME/$2
echo `realpath $PWD/$DIRNAME/$1`:'->':`realpath $HOME/$2`
} }
make_link zshrc .zshrc
make_link vimrc .vimrc function main {
make_link init.vim .config/nvim/init.vim
make_link awesome .config/awesome make_link zshrc .zshrc
make_link gitconfig .gitconfig make_link vimrc .vimrc
make_link ycm_extra_conf.py .vim/ycm_extra_conf.py
make_link init.vim .config/nvim/init.vim
make_link awesome .config/awesome
make_link gitconfig .gitconfig
}
main | column -t -s ':'

4
vimrc
View File

@ -19,6 +19,10 @@ Plugin 'suan/vim-instant-markdown'
Plugin 'Valloric/YouCompleteMe' Plugin 'Valloric/YouCompleteMe'
" Generate doc for typescript functions " Generate doc for typescript functions
Plugin 'https://gogs.tforgione.fr/tforgione/typescript-doc.git' Plugin 'https://gogs.tforgione.fr/tforgione/typescript-doc.git'
" Coloration for javascript
Plugin 'jelera/vim-javascript-syntax'
" Coloration for typescript
Plugin 'leafgarland/typescript-vim'
call vundle#end() " required call vundle#end() " required
filetype plugin indent on " required filetype plugin indent on " required

195
ycm_extra_conf.py Normal file
View File

@ -0,0 +1,195 @@
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall', '-DNDEBUG', '-DUSE_CLANG_COMPLETER','-Wno-missing-braces',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++1y'.
'-std=c++14',
'-I', '/usr/include/atkmm-1.6',
'-I', '/usr/include/gtk-3.0/unix-print',
'-I', '/usr/include/gdkmm-3.0',
'-I', '/usr/lib/gdkmm-3.0/include',
'-I', '/usr/include/giomm-2.4',
'-I', '/usr/lib/giomm-2.4/include',
'-I', '/usr/include/pangomm-1.4',
'-I', '/usr/lib/pangomm-1.4/include',
'-I', '/usr/include/glibmm-2.4',
'-I', '/usr/lib/glibmm-2.4/include',
'-I', '/usr/include/gtk-3.0',
'-I', '/usr/include/at-spi2-atk/2.0',
'-I', '/usr/include/gtk-3.0',
'-I', '/usr/include/gio-unix-2.0/',
'-I', '/usr/include/cairo',
'-I', '/usr/include/pango-1.0',
'-I', '/usr/include/atk-1.0',
'-I', '/usr/include/cairo',
'-I', '/usr/include/cairomm-1.0',
'-I', '/usr/lib/cairomm-1.0/include',
'-I', '/usr/include/cairo',
'-I', '/usr/include/pixman-1',
'-I', '/usr/include/freetype2',
'-I', '/usr/include/libpng16',
'-I', '/usr/include/harfbuzz',
'-I', '/usr/include/freetype2',
'-I', '/usr/include/harfbuzz',
'-I', '/usr/include/libdrm',
'-I', '/usr/include/libpng16',
'-I', '/usr/include/sigc++-2.0',
'-I', '/usr/lib/sigc++-2.0/include',
'-I', '/usr/include/gdk-pixbuf-2.0',
'-I', '/usr/include/libpng16',
'-I', '/usr/include/glib-2.0',
'-I', '/usr/lib/glib-2.0/include' ,
# '-I', '/lib/emscripten/system/include',
'-I', '/usr/include/qt' ,
'-I', '/usr/include/OGRE' ,
# '-I', '/home/thomas/Prog/C++/MGS/include',
# '-I', '/home/thomas/Prog/C++/Paella/Code/include',
# '-I', '/home/thomas/Prog/C++/controller/include',
'-I', '/opt/android-ndk/platforms/android-21/arch-arm/usr/include',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', 'c++'
]
def genPackageConfig(flags, package_name):
def not_whitespace(string):
return not (string == '' or string == '\n')
stream = os.popen("pkg-config --cflags " + package_name)
includes = stream.read().split(' ')
includes = filter(not_whitespace, includes)
return flags + includes
flags = genPackageConfig(flags, 'gtkmm-3.0')
flags = genPackageConfig(flags, 'opencv')
# 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
#
# 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
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
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
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}