From: Samir Benmendil Date: Wed, 5 Nov 2014 11:18:52 +0000 (+0000) Subject: vim: fix ycm for rospack (and probably others) X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/04b521f057e089a7f445d75f792bf7ae3a3273c6 vim: fix ycm for rospack (and probably others) --- diff --git a/vim/vimrc b/vim/vimrc index d4e8e48..31bc4b0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -442,6 +442,7 @@ let g:UltiSnipsSnippetsDir = "$XDG_CONFIG_HOME/vim/ultisnips" " youcompleteme {{{2 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*'] let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py') +let g:ycm_extra_conf_vim_data = ['getcwd()'] let g:ycm_add_preview_to_completeopt = 1 let g:ycm_autoclose_preview_window_after_insertion = 1 "let g:ycm_extra_conf_vim_data = ['%:p'] diff --git a/vim/ycm_extra_conf.py b/vim/ycm_extra_conf.py index 391fa8c..ba18821 100644 --- a/vim/ycm_extra_conf.py +++ b/vim/ycm_extra_conf.py @@ -3,29 +3,40 @@ import shlex import subprocess 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', -# '-Wextra', -# '-Wshadow', -# '-Werror', -# '-Wc++98-compat', -# '-Wno-long-long', -# '-Wno-variadic-macros', -# '-fexceptions', -# '-DNDEBUG', -'-std=c++11', -'-stdlib=libc++', -'-x', 'c++', -'-I', '.', -'-I', './include', -'-isystem', '/usr/include/c++/4.9.0', -'-isystem', '/usr/include/c++/4.9.0/x86_64-unknown-linux-gnu', -'-isystem', '/usr/include/c++/4.9.0/backward', -'-isystem', '/usr/lib/clang/3.4.1/include' -] +def FlagsForFile( filename, **kwargs ): + client_data = kwargs['client_data'] + cwd = client_data['getcwd()'] + # These are the compilation flags that will be used in case there's no + # compilation database set (by default, one is not set). + flags = [ + '-Wall', + # '-Wextra', + # '-Wshadow', + # '-Werror', + # '-Wc++98-compat', + # '-Wno-long-long', + # '-Wno-variadic-macros', + # '-fexceptions', + # '-DNDEBUG', + '-std=c++11', + '-stdlib=libc++', + '-x', 'c++', + '-I', '.', + '-I', './include', + '-isystem', '/usr/include/c++/4.9.0', + '-isystem', '/usr/include/c++/4.9.0/x86_64-unknown-linux-gnu', + '-isystem', '/usr/include/c++/4.9.0/backward', + '-isystem', '/usr/lib/clang/3.4.1/include' + ] + flags += rospack() + relative_to = cwd + final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) + print flags + + return { + 'flags': final_flags, + 'do_cache': True + } # This function makes it easy to pull in additional flags from rospack def rospack(): @@ -43,7 +54,6 @@ def rospack(): includes += ['-isystem', include] return filter(lambda a: a != ' ', includes) -flags += rospack() def DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) ) @@ -76,11 +86,3 @@ def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): new_flags.append( new_flag ) return new_flags -def FlagsForFile( filename, **kwargs ): - relative_to = DirectoryOfThisScript() - final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) - - return { - 'flags': final_flags, - 'do_cache': True - }