Skip to content

Commit d13595d

Browse files
committed
Support gf inside of engines
1 parent a56db85 commit d13595d

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

after/ftplugin/ruby/rails.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if !exists('*RailsDetect') || !RailsDetect()
1+
if (!exists('*RailsDetect') || !RailsDetect()) && expand('%:p') !~# '.*\ze[\/]\%(app\|config\|lib\|test\|spec\)[\/]'
22
finish
33
endif
44

autoload/rails.vim

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4869,29 +4869,37 @@ function! rails#webpacker_setup(type) abort
48694869
endfunction
48704870

48714871
function! rails#ruby_setup() abort
4872-
if !s:active()
4873-
return
4874-
endif
4875-
let path = rails#app().internal_load_path()
4876-
let path += [rails#app().path('app/views')]
4877-
if len(rails#buffer().controller_name())
4878-
let path += [rails#app().path('app/views/'.rails#buffer().controller_name()), rails#app().path('app/views/application')]
4879-
endif
4880-
let format = rails#buffer().format(0)
48814872
let exts = ['raw', 'erb', 'html', 'builder', 'ruby', 'coffee', 'haml', 'jbuilder']
4882-
call extend(exts,
4883-
\ filter(map(keys(rails#app().projections()),
4884-
\ 'matchstr(v:val, "^\\Capp/views/\\*\\.\\zs(\\w\\+$")'), 'len(v:val)'))
4873+
if s:active()
4874+
let path = rails#app().internal_load_path()
4875+
let path += [rails#app().path('app/views')]
4876+
if len(rails#buffer().controller_name())
4877+
let path += [rails#app().path('app/views/'.rails#buffer().controller_name()), rails#app().path('app/views/application')]
4878+
endif
4879+
call add(path, rails#app().path())
4880+
if !rails#app().has_rails5()
4881+
let path += [rails#app().path('vendor/plugins/*/lib'), rails#app().path('vendor/rails/*/lib')]
4882+
endif
4883+
call extend(exts,
4884+
\ filter(map(keys(rails#app().projections()),
4885+
\ 'matchstr(v:val, "^\\Capp/views/\\*\\.\\zs(\\w\\+$")'), 'len(v:val)'))
4886+
else
4887+
let full = matchstr(expand('%:p'), '.*[\/]\%(app\|config\|lib\|test\|spec\)\ze[\/]')
4888+
let name = fnamemodify(full, ':t')
4889+
let dir = fnamemodify(full, ':h')
4890+
if len(dir) && (name ==# 'app' || s:isdirectory(dir . '/app')) && (name ==# 'lib' || s:isdirectory(dir . '/lib'))
4891+
let path = [dir . '/app/*', dir . '/lib']
4892+
else
4893+
return
4894+
endif
4895+
endif
4896+
let format = matchstr(expand('%:p'), '[\/]app[\/]views[\/].*\.\zs\w\+\ze\.\w\+$')
48854897
for ext in exts
48864898
if len(format)
48874899
exe 'setlocal suffixesadd+=.' . format . '.' . ext
48884900
endif
48894901
exe 'setlocal suffixesadd+=.' . ext
48904902
endfor
4891-
if !rails#app().has_rails5()
4892-
let path += [rails#app().path('vendor/plugins/*/lib'), rails#app().path('vendor/rails/*/lib')]
4893-
endif
4894-
call add(path, rails#app().path())
48954903

48964904
let engine_paths = s:gem_subdirs('app')
48974905
call rails#update_path(path, engine_paths)

0 commit comments

Comments
 (0)