vim-rails icon indicating copy to clipboard operation
vim-rails copied to clipboard

gf doesn't work for partials for me?

Open thomaswitt opened this issue 1 year ago • 6 comments
trafficstars

Hi everybody,

I have a strange thing, gf works fine for me e.g. when in a Controller, it jumps to the model, when I have a partial, it jumps to the partial.

But when I render something from layout, it doesnt work: <%= render 'layouts/search' %>

gf on layouts/search doesn't work. All I get is E345: Can't fnd file "layouts/search" in path …

Yes, I have seen other issues and therefore it should be working but I don't know why it doesn't. Any idea?

thomaswitt avatar Jan 12 '24 16:01 thomaswitt

Mine is doing this too, after switching to using LazyVim and updating my config to use lua.

:) I'm still working on figuring it out - but I'll update this here if I have any luck

thewatts avatar Jan 20 '24 02:01 thewatts

Update: It looks like nvim-treesitter is causing things to break on my end.

If I disable it, gf starts working again.

thewatts avatar Jan 20 '24 02:01 thewatts

Agreed -> nvim-treesitter seems to break the gf command to go find partials. Is there a way to give vim-rails command precedence? I'm assuming something in tree-sitter must also be relying on that same command.

awortham avatar Jan 30 '24 19:01 awortham

Potentially related: https://github.com/nvim-treesitter/nvim-treesitter/issues/6187

thewatts avatar Feb 27 '24 12:02 thewatts

My gf couldn't find partials either. After adding additional_vim_regex_highlighting = true, to my treesitter config per this comment, gf works as expected.

natematykiewicz avatar Mar 06 '24 05:03 natematykiewicz

or add the following code in your .vimrc if you don't want set additional_vim_regex_highlighting = true

augroup vim-rails-augroup
  autocmd!
  autocmd FileType eruby
        \ if RailsDetect() | cmap <buffer><script><expr> <Plug><cfile> rails#ruby_cfile() | endif
augroup END

jiz4oh avatar Aug 06 '24 06:08 jiz4oh