Ctags generate latest version gems
Asked Answered
D

3

5

I use vim-rails and ctags for navigate of methods. For it I run ctags -R * in /home/***/.rvm/gems/ruby***/gems. But in this directory was many folders for one gems just different versions(for example activerecord v. 3.0.7/3.1.3/3.2.2/3.2.3). And when I try go to(ctrl+]) method I get to old version. How I can run ctags only with latest gems version?

Dunsinane answered 12/4, 2012 at 19:12 Comment(0)
A
12

You can make bundler show the locations for the gems in the gemfile with

bundle show --paths

If you pipe this list into ctags I think you will have what you need.

bundle show --paths | xargs ctags -R

edit: Summarized in this blogpost: http://heim.no/VIM/2012/04/19/generate-ctags-for-all-bundled-gems-in-a-ruby-project/

Aeniah answered 13/4, 2012 at 14:27 Comment(4)
Andreas, thanks for the info. I posted this question on your blog a few months ago but haven't gotten around it: I've found a problem in that, I can only go to the tags when I'm originating from a file in my project. Once I'm in a file that is contained in one of the gems I'm using, I can't follow any of the methods called in that file to it's method definition. I believe it's because it doesn't know how to find the ctags file relative to the file I'm currently browsing. Have you had any problems like I'm seeing?Nakada
Tony, seems like I actually have to check this out a bit and post an update (as I said a couple of months ago) :)Aeniah
This is great. But it generates ctags only for gems. How do i make it generate for both gems and current project?Macro
@Macro I posted answer to this belowWarrenwarrener
W
1

If you want to add tags for your project along with the gemfile tags you can use -a option to append so you can just do:

ctags -R -f .tags && bundle show --paths | xargs ctags -R -a -f .tags
Warrenwarrener answered 10/8, 2018 at 3:12 Comment(0)
A
0

Work-around: I'm not sure of a direct method, but you always have the option of editing the "tags" file manually, search/replace for all older gems versions and delete them or maybe delete all gems related sections and later on you can append to the tags file using [ctags -a 3.2.3]

Ajani answered 12/4, 2012 at 19:42 Comment(1)
Yes, I know. But tags file has more than 63000 rows and editing manually is not good idea. And remove all gems expect for the latest version is not good idea too, because I may need later older gems version. My first question is not correct. How I can use gems version which used in Gemfile?Dunsinane

© 2022 - 2024 — McMap. All rights reserved.