Regenerate ctags in vim using RVM
I have the following code in my .vimrc:
map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
This generates 开发者_C百科ctags for my current directory.
I'm using RVM, I'm working on different projects, with different ruby versions (trough RVM gemsets.
I have a different $GEM_PATH per project, and I want to generate the ctags for the gems in this path too.
How should the above line be to test if the $GEM_PATH variable is set, and processing these paths too?
Or better still how to check if I have an .rvmrc file, and generate ctags depending of the contents of this file?
I use bundler to manage gems, so I use
ctags -R `bundle show rails`/../*
to get the tags for gems.
If you're using rvm, you can use rvm gemdir
. For example, this is what I'm using:
map <Leader>rt :!ctags --extra=+f --exclude=.git --exclude=log -R * `rvm gemdir`/gems/*<CR><CR>
This will always use the gem directory in your current rvm gemset.
Generic version for tagging all the installed gems (it takes a while):
map <silent><Leader>rt :!ctags --extra=+f --exclude=.git --exclude=log -R * `gem environment gemdir`/gems/*<CR><CR>
If you want to just tag bundled gems (much faster):
map <silent> <Leader>rt :!bundle list --paths=true \| xargs ctags --extra=+f --exclude=.git --exclude=log -R *<CR><CR>
This works well for me:
map <Leader>rt :!/usr/local/bin/ctags --language-force=ruby --exclude=.git --exclude=log -R * `bundle show --paths`
Adding --language-force=ruby in order to reduce the size of tags file and make it clean.
That is what I use:
ctags -R --exclude=.git --exclude=log * $(rvm gemdir)
I'm not sure if this will help you in your situation by I do know of a quirk on macs that require me to run sudo mv /etc/zshenv /etc/zprofile
every time I install vim to get exuberant with Rails.vim (Rtags) to work. For more see this post:
$PATH variable not properly set in gvim/MacVim when it is opened from the finder
精彩评论