Git Product home page Git Product logo

gem-ctags's Introduction

RubyGems Automatic Ctags Invoker

Nary a day of Ruby development goes by where I don't run gem open or bundle open. And when I go rooting around in a gem, I want tags. As good as I've gotten at ctags -R ., I've grown weary of it. So I wrote a RubyGems plugin to automatically invoke Ctags on gems as they are installed.

Installation

If you haven't already, install Exuberant Ctags and make sure it comes first in $PATH. With Homebrew, brew install ctags. Now all that's left to do is install gem-ctags and perform a one-off indexing of the gems that are already installed:

gem install gem-ctags
gem ctags

If you're using RVM, I recommend extending your global gemset by adding gem-ctags to ~/.rvm/gemsets/global.gems. Put it at the top so the gems below it will be indexed.

Troubleshooting

If you see

$ ctags -R
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...

you do not have the correct version of ctags in your path.

Just add the following to your .bashrc and be happy:

export PATH=/usr/local/bin:$PATH

Vim Tips

To easily edit a gem with your current working directory set to the gem's root, install gem-browse.

If you have rake.vim installed (which, by the way, is a misleading name), Vim will already know where to look for the tags file when editing a gem.

If you have bundler.vim installed, Vim will be aware of all tags files from all gems in your bundle.

If you want to get crazy, add this to your vimrc to get Vim to search all gems in your current RVM gemset (requires pathogen.vim):

autocmd FileType ruby let &l:tags = pathogen#legacyjoin(pathogen#uniq(
      \ pathogen#split(&tags) +
      \ map(split($GEM_PATH,':'),'v:val."/gems/*/tags"')))

I don't like to get crazy.

Contributing

Don't submit a pull request with an ugly commit message or I will ignore your patch until I have the energy to politely explain my zero tolerance policy.

License

Copyright (c) Tim Pope. MIT License.

gem-ctags's People

Contributors

cbartlett avatar ixti avatar jacobthemyth avatar koronen avatar lzap avatar nilshaldenwang avatar tpope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gem-ctags's Issues

alternate output file?

Looks like 'gem ctags' stores output in ./gems.tags.

Is there a command-line or config-file option to direct the output to a different file?

warning: conflicting chdir during another chdir block

Whenever I run bundle install, I get the following warnings:

/Users/p0deje/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/shared_helpers.rb:53: warning: conflicting chdir during another chdir block
/Users/p0deje/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gem-ctags-1.0.6/lib/rubygems/commands/ctags_command.rb:23: warning: conflicting chdir during another chdir block
/Users/p0deje/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gem-ctags-1.0.6/lib/rubygems/commands/ctags_command.rb:23: warning: conflicting chdir during another chdir block

Weird filename generated in tags file

Take tags for gem activesupport-6.0.3.1 example

The tags for html_safe are something like:

$ ag html_safe tags

1230:html_safe  lib/active_support/core_ext/string/oy.rbt_safety.rb     /^  def html_safe$/;"    f       class:String
1231:html_safe? lib/active_support/core_ext/string/oy.rbt_safety.rb     /^    def html_safe?$/;" f       class:ActiveSupport.SafeBuffer
1232:html_safe? lib/active_support/core_ext/string/oy.rbt_safety.rb     /^  def html_safe?$/;"   f       class:Numeric

The file names are oy.rbt_safety.rb in tags files.It should be output_safety.rb.

I'm using:

ruby 2.7.1p83
Ctags 5.8

Error with ruby 2.0.0p0

I'm getting this error when using gem-ctags with ruby v2.0.0p0:

ERROR:  While executing gem ... (Errno::EISDIR)
Is a directory - tags

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

None new gems get installed via Bundler

After installing this gem, now whenever I run bundle install, I always get the following msg and none of the new gems or its dependencies gets installed.

bundle
...
....
Using gmaps4rails (1.5.6) 
Installing listen (0.6.0) 
LoadError: cannot load such file -- rubygems/commands/ctags_command
An error occurred while installing listen (0.6.0), and Bundler cannot continue.
Make sure that `gem install listen -v '0.6.0'` succeeds before bundling.

I've installed ctags via homebrew and the $PATH is:

echo $PATH                                                                                         1.9.3-p194@global 
/Users/millisami/.rbenv/shims:/Users/millisami/.rbenv/bin:/usr/local/share/npm/bin:/Users/millisami/.oh-my-zsh/custom/shell-scripts:/usr/local/bin:/Users/millisami/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/deployd/bin:/usr/local/git/bin:/usr/X11/bin

Do I've to do some conf change for the bundle to run without the above error?

dosn't generate ctags for gems that is not in global gemset

ruby 1.9.3-p0
rvm 1.9.2

gem ctags --debug:

Exception `NameError' at /home/anton/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:177 - uninitialized constant Gem::Commands::CtagsCommand
Exception `LoadError' at /home/anton/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36 - cannot load such file -- rubygems/commands/ctags_command

First run of gem ctags made ctags for a few installed gems(clean ruby). And I am getting this error after bundle install has already been run and gem ctags has been run second time.

Any help? Thanks

gem ctags command does nothing

gem ctags command is not doing anything after I upgraded to Yosemite. I tried --debug option but nothing is happening and no error is being thrown. ctags -R is running fine.

[vim] - does not work for gems not installed via 'bundle install'

So let's say I have the following in my Gemfile and I install with bundle install:

source 'https://rubygems.org' 
gem 'activesupport' 

I generate the tags with gem ctags, then edit a file in vim in the same dir as the Gemfile:

require 'active_support/all'
puts 1.month.ago

I can now do gf while cursor is on 'active_support' and also <c-]> when cursor is on 'ago'. These both work leading to the file and definition respectively.

However if I retry the same scenario, but instead of having a Gemfile, I just do 'gem install activesupport', I get:

E345: Can't find file "active_support/all.rb" in path
E426: tag not found: ago

Is there a way to make this work for a ruby file edited outside of a project, if the currently used ruby version already has that gem installed? I am using rbenv, and also have installed the plugins suggested as Vim Tips:

Plug 'tpope/vim-rake'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-rbenv'

Thanks

Question about usage with bundler

So I noticed that tags aren't generated for gems installed through bundler and stumbled over your attempts to solve this. If I understand correctly this is still/again broken in current Bundler releases, and I was wondering if you found a way to work around it?

vim ctags not found tags in rails project

I have generated tags file on gem's root for my Rails project by running gem ctags, but when I stop the cursor in rails keywords, such as 'before_action', then I type ctrl - ], it tips me "No tags found for: before_action".

By the way, ctags works normally for my project's methods and class tags.

Did I do something wrong? And what should I do?

My native language is not English, please forgive me for any mistakes.

OptionParser throwing an InvalidOption error.

I'm seeing the following upon running gem ctags --debug with gem-ctags (1.0.7):

Exception `OptionParser::InvalidOption' at ~/.rbenv/versions/2.1.2/lib/ruby/2.1.0/optparse.rb:1543 - invalid option: no-ri
Exception `OptionParser::InvalidOption' at ~/.rbenv/versions/2.1.2/lib/ruby/2.1.0/optparse.rb:1355 - invalid option: --no-ri
Exception `OptionParser::InvalidOption' at ~/.rbenv/versions/2.1.2/lib/ruby/2.1.0/optparse.rb:1543 - invalid option: no-rdoc
Exception `OptionParser::InvalidOption' at ~/.rbenv/versions/2.1.2/lib/ruby/2.1.0/optparse.rb:1355 - invalid option: --no-rdoc

Will poke at it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.