JnBrymn
JnBrymn

Reputation: 25363

In rails.vim why do I get "E345 can't find file in path" errors?

I've been learning Ruby/Rails with vim. Tim Pope's rails.vim seems like a really good tool to traverse files with, but I keep getting these pesky "E345 can't find file in path" errors. I'm not vim expert yet, so the solution isn't obvious. Additionally, I've tried this and it doesn't apply to my problem.

As an example of the problem. I have a method format_name defined in app/helpers/application_helper.rb and it is used in app/helpers/messages_helper.rb. Within the latter file I put my cursor over the usage of format_name and then hit gf and I get that error. Similar disfunction with commands like ]f and [f

However, it works sometimes. I was able to gf from user to the app/models/user.rb

Ideas?

Upvotes: 7

Views: 1630

Answers (1)

Chris Johnsen
Chris Johnsen

Reputation: 224691

I think that is a limitation of rails.vim. It does not support “finding” bare methods. Supporting something like that would require one of the following:

  • an exhaustive search of all the source files for each “find” request
    (which could be expensive with large projects),
  • “dumb” indexing of method names
    (e.g. Exuberant Ctags and gControl-]; see :help g_CTRL-]), or
  • smart enough parsing of the code to make a good guess where the method might be defined
    (which is hard to do properly).

If you know where the method is, you can extend many of the navigation commands with a method name:

:Rhelper application#format_name

But, you do not have to type all of that in. Assuming the cursor is on format_name you can probably just type:RhTabspaceappTab#Control-R Control-W (see :help c_CTRL-R_CTRL-W).

Upvotes: 1

Related Questions