tpope / vim-rails

rails.vim: Ruby on Rails power tools
http://www.vim.org/scripts/script.php?script_id=1567
4.11k stars 384 forks source link

'gf' leads to error E345 can't find file "<Plug>User.find_by_email" in path #492

Closed Feuda closed 5 years ago

Feuda commented 7 years ago

user = User.find_by_email(email) #rails code

'gf' on the word 'User', it occured

E345 can't find file "<Plug>User.find_by_email" in path

Any ideas?

tpope commented 7 years ago

Check :verb cmap <Plug><cfile>.

Feuda commented 7 years ago

@tpope ouput as c <Plug><cfile> &@rails#cfile() Last set from ~/.vim/bundle/vim-rails/autoload/rails.vim Press ENTER or type command to continue after running:verb cmap <Plug><cfile>

tpope commented 7 years ago

That's correct. Can you check :verb nmap gf? Edit: And :verb nmap <Plug>RailsFind.

Also go ahead and report your exact Vim version.

Feuda commented 7 years ago

:verb nmap gf outputs

wx20170720-124400 2x

:verb nmap <Plug>RailsFind outputs

wx20170720-124630 2x

vim --version outputs

wx20170720-125449 2x
tpope commented 7 years ago

I'm running out of ideas. Can you check what <C-R><C-F> does on the : command line? It should insert user.rb, but if it fails like gf it will insert <Plug>User.find_by_email. Go ahead and check :cmap <C-R><C-F> while you're at it.

peyloride commented 7 years ago

I have same problem. I check what you ask from @Feuda and my output same as him. But i did not understand your last request, @tpope. Forgive me, it just have been 1 weeks using vim.

I did try this command but :<C-R><C-F> it gaves an error: E488: Trailing characters

:cmap <C-R><C-F> outputs: c <C-R><C-F> @<Plug><cfile>

tpope commented 7 years ago

Press CTRL-R CTRL-F on the command line.

Feuda commented 7 years ago
wx20170809-122002 2x wx20170809-122158 2x

@tpope

tpope commented 6 years ago

The maps all look fine, so I think it's just an issue with the actual logic to determine the the filename. Can you try again on the latest? I've fixed a lot of bugs in that area. You can also check :echo rails#ruby_cfile() to make sure that matches up with the destination file.

Feuda commented 6 years ago
image image image image

@tpope

tpope commented 6 years ago

Okay, that <Plug> in there is definitely something different happening. Can you report on these again?

verbose cmap <Plug><cfile>
verbose nmap gf
Feuda commented 6 years ago
image image image image

@tpope

tpope commented 6 years ago

Okay, I said "something different" but after re-reading your original issue it is the same thing. What's supposed to happen is gf expands to :find <Plug><cfile> and <Plug><cfile> expands to the return value of rails#ruby_cfile(). But that second expansion isn't happening, and instead :find substitutes the raw filename under the cursor for <cfile>, hence <Plug>Account.account_types.

Since something is going horribly wrong with map expansion, I'm inclined to have you check these related options:

:verbose set timeout? timeoutlen? ttimeout? ttimeoutlen?
Feuda commented 6 years ago
image image

@tpope

tpope commented 6 years ago

Those are fine. I'm out of easy things to check. Try stripping your config down to a minimal vimrc and rails.vim only, and see if you can still reproduce the problem.

wail-fajr-rd commented 5 years ago

Hello, I had the same problem as in this ticket and try all the steps until I started stripping my config down. I finally got "gf" to work after I removed "set paste".

tpope commented 5 years ago

:set paste is designed to be temporarily switched on before pasting something in your terminal. It disables a ton of Vim features, including auto-indenting and all insert mode and command line mode maps. Never, ever, ever, ever, ever, ever set it in your vimrc.

Thanks for sharing the results of your investigation. I wouldn't have thought to check for that otherwise.

wail-fajr-rd commented 5 years ago

Thanks for your explanation, I had no idea :set paste was this dangerous.