]> git.rmz.io Git - dotfiles.git/commitdiff
vim: fix ycm for rospack (and probably others)
authorSamir Benmendil <samir.benmendil@gmail.com>
Wed, 5 Nov 2014 11:18:52 +0000 (11:18 +0000)
committerSamir Benmendil <samir.benmendil@gmail.com>
Wed, 5 Nov 2014 11:18:52 +0000 (11:18 +0000)
vim/vimrc
vim/ycm_extra_conf.py

index d4e8e489a404e4536327a3aac0c551676644a0ad..31bc4b008c0bc5a08c378838983e051b446d9a75 100644 (file)
--- 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']
index 391fa8c029e634836affa458cb157c6592e7e4e9..ba188217009cb151d2f7e952378053eb66934c10 100644 (file)
@@ -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
-  }