Skip to content

Commit

Permalink
Support 1.9 hash syntax with gf
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Dec 28, 2010
1 parent 26dade8 commit 17d97f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions autoload/rails.vim
Expand Up @@ -1860,7 +1860,7 @@ function! s:findamethod(func,repl)
endfunction

function! s:findasymbol(sym,repl)
return s:findit('\s*:\%('.a:sym.'\)\s*=>\s*(\=\s*[@:'."'".'"]\(\f\+\)\>.\=',a:repl)
return s:findit('\s*\%(:\%('.a:sym.'\)\s*=>\|\<'.a:sym.':\)\s*(\=\s*[@:'."'".'"]\(\f\+\)\>.\=',a:repl)
endfunction

function! s:findfromview(func,repl)
Expand Down Expand Up @@ -1915,10 +1915,10 @@ function! s:RailsFind()
let res = s:findasymbol('to','app/controllers/\1')
if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif

let res = s:findamethod('root\s*:to\s*=>\s*','app/controllers/\1')
let res = s:findamethod('root\s*\%(:to\s*=>\|\<to:\)\s*','app/controllers/\1')
if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif

let res = s:findamethod('\%(match\|get\|put\|post\|delete\|redirect\)\s*(\=\s*[:''"][^''"]*[''"]\=\s*\%(,\s*:to\s*\)\==>\s*','app/controllers/\1')
let res = s:findamethod('\%(match\|get\|put\|post\|delete\|redirect\)\s*(\=\s*[:''"][^''"]*[''"]\=\s*\%(\%(,\s*:to\s*\)\==>\|,\s*to:\)\s*','app/controllers/\1')
if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif

let res = s:findamethod('layout','\=s:findlayout(submatch(1))')
Expand All @@ -1942,17 +1942,17 @@ function! s:RailsFind()
let res = s:sub(s:sub(s:findasymbol('partial','\1'),'^/',''),'\k+$','_&')
if res != ""|return res."\n".s:findview(res)|endif

let res = s:sub(s:sub(s:findfromview('render\s*(\=\s*:partial\s\+=>\s*','\1'),'^/',''),'\k+$','_&')
let res = s:sub(s:sub(s:findfromview('render\s*(\=\s*\%(:partial\s\+=>\|partial:\)\s*','\1'),'^/',''),'\k+$','_&')
if res != ""|return res."\n".s:findview(res)|endif

let res = s:findamethod('render\s*:\%(template\|action\)\s\+=>\s*','\1.'.format.'\n\1')
let res = s:findamethod('render\>\s*\%(:\%(template\|action\)\s\+=>\|template:\|action:\)\s*','\1.'.format.'\n\1')
if res != ""|return res|endif

let res = s:sub(s:findfromview('render','\1'),'^/','')
if buffer.type_name('view') | let res = s:sub(res,'[^/]+$','_&') | endif
if res != ""|return res."\n".s:findview(res)|endif

let res = s:findamethod('redirect_to\s*(\=\s*:action\s\+=>\s*','\1')
let res = s:findamethod('redirect_to\s*(\=\s*\%\(:action\s\+=>\|\<action:\)\s*','\1')
if res != ""|return res|endif

let res = s:findfromview('stylesheet_link_tag','public/stylesheets/\1')
Expand Down

0 comments on commit 17d97f6

Please sign in to comment.