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?
Ctags generate latest version gems
Asked Answered
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/
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 below –
Warrenwarrener
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
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]
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.