diff --git a/doc/rake.txt b/doc/rake.txt index 7be877c..878b257 100644 --- a/doc/rake.txt +++ b/doc/rake.txt @@ -71,6 +71,13 @@ COMMANDS *rake-commands* Set g:rake_legacy to 1 to enable the old, legacy R command variants. This option will eventually be removed. + *rake-ruby-c-extensions* +This plugin supports Ruby C extension files usually located under ext/. +For those C files 'path' is enhanced with correct Ruby include directory. +With this you can use |i_CTRL-X_CTRL-I| completion and |[i|, |[d| families of +mappings and commands on all the macros and functions provided by ruby.h +header file. + ABOUT *rake-about* Grab the latest version or report a bug on GitHub: diff --git a/plugin/rake.vim b/plugin/rake.vim index e876bd7..b61be44 100644 --- a/plugin/rake.vim +++ b/plugin/rake.vim @@ -208,7 +208,21 @@ function! s:project_path(...) dict abort return join([self._root]+a:000,'/') endfunction -call s:add_methods('project',['path']) +function! s:project_ruby_include_path() dict abort + if !has_key(self, '_ruby_include_path') + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' + let cwd = getcwd() + try + execute cd fnameescape(self.path()) + let self._ruby_include_path = system('ruby -rrbconfig -e "print RbConfig::CONFIG[\"rubyhdrdir\"] || RbConfig::CONFIG[\"topdir\"]"') + finally + execute cd fnameescape(cwd) + endtry + endif + return self._ruby_include_path +endfunction + +call s:add_methods('project',['path','ruby_include_path']) " }}}1 " Rake {{{1 @@ -323,6 +337,10 @@ augroup rake_path \ let &l:path = escape(s:project().path('lib'),', ') \ . ',' . escape(s:project().path('ext'),', ') . ',' . &path | \ endif + autocmd User Rake + \ if &filetype ==# 'c' || &filetype ==# 'cpp' | + \ let &l:path = escape(s:project().ruby_include_path(),', ') . ',' . &path | + \ endif augroup END " }}}1