Regenerate ctags in vim using RVM
Asked Answered
S

6

13

I have the following code in my .vimrc:

map <Leader>rt :!ctags --extra=+f -R *<CR><CR>

This generates 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?

Shredding answered 27/12, 2010 at 14:14 Comment(0)
Z
14

I use bundler to manage gems, so I use

ctags -R `bundle show rails`/../*

to get the tags for gems.

Zipangu answered 27/12, 2010 at 15:8 Comment(2)
There should be backtics around the bundle command—can't get SO to render those properlyZipangu
If you've upgraded gems then `bundle show rails` will tag all of the gems you've ever used. Better to use something like this: ctags -e --exclude=.git --exclude='*.log' -R * `bundle show --paths`Provide
S
11

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.

Suggestion answered 13/5, 2011 at 23:10 Comment(1)
Is it possible to use this to generate tags only for the latest version of each gem?Kino
K
6

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> 
Kimikokimitri answered 27/3, 2012 at 12:1 Comment(0)
J
3

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.

Jeep answered 24/12, 2012 at 14:58 Comment(0)
D
2

That is what I use:

ctags -R --exclude=.git --exclude=log * $(rvm gemdir)
Designate answered 19/2, 2013 at 23:22 Comment(0)
P
0

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

Pyroclastic answered 20/5, 2012 at 23:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.