Skip to content

Commit 39cb87d

Browse files
committed
Smarter gf on class level declarations
1 parent 4551af7 commit 39cb87d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

autoload/rails.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,20 @@ function! s:ruby_cfile() abort
24572457
endif
24582458
endif
24592459

2460+
let declpat = '^\(\s*\)\(\w\+\)\>\s*(\=\s*:\=\([''"]\=\)\(\%(\w\|::\)\+\)\3'
2461+
let decl = matchlist(getline('.'), declpat)
2462+
if len(decl) && len(decl[0]) >= col('.')
2463+
let declid = synID(line('.'), 1+len(decl[1]), 1)
2464+
let declbase = rails#underscore(decl[4])
2465+
if declid ==# hlID('rubyEntities')
2466+
return rails#singularize(declbase) . '.rb'
2467+
elseif declid ==# hlID('rubyEntity') || decl[4] =~# '\u'
2468+
return declbase . '.rb'
2469+
elseif index([hlID('rubyMacro'), hlID('rubyAttribute')], declid) >= 0
2470+
return rails#singularize(declbase) . '.rb'
2471+
endif
2472+
endif
2473+
24602474
let synid = synID(line('.'), col('.'), 1)
24612475
let old_isfname = &isfname
24622476
try

0 commit comments

Comments
 (0)