@@ -1810,72 +1810,100 @@ function! s:findasymbol(sym,repl)
18101810endfunction
18111811
18121812function ! s: findfromview (func ,repl)
1813+ " ( ) ( ) ( \1 ) ( )
18131814 return s: findit (' \s*\%(<%\)\==\=\s*\<\%(' .a: func .' \)\s*(\=\s*[@:' ." '" .' "]\(\f\+\)\>[' ." '" .' "]\=\s*\%(%>\s*\)\=' ,a: repl )
18141815endfunction
18151816
18161817function ! s: RailsFind ()
18171818 if filereadable (expand (" <cfile>" ))
18181819 return expand (" <cfile>" )
18191820 endif
1821+
18201822 " UGH
18211823 let format = s: format (' html' )
1824+
18221825 let res = s: findit (' \v\s*<require\s*\(=\s*File.dirname\(__FILE__\)\s*\+\s*[:' ." '" .' "](\f+)>.=' ,expand (' %:h' ).' /\1' )
18231826 if res != " " |return res .(fnamemodify (res ,' :e' ) == ' ' ? ' .rb' : ' ' )|endif
1827+
18241828 let res = s: findit (' \v<File.dirname\(__FILE__\)\s*\+\s*[:' ." '" .' "](\f+)>[' ." '" .' "]=' ,expand (' %:h' ).' \1' )
18251829 if res != " " |return res |endif
1830+
18261831 let res = rails#underscore (s: findit (' \v\s*<%(include|extend)\(=\s*<(\f+)>' ,' \1' ))
18271832 if res != " " |return res ." .rb" |endif
1833+
18281834 let res = s: findamethod (' require' ,' \1' )
18291835 if res != " " |return res .(fnamemodify (res ,' :e' ) == ' ' ? ' .rb' : ' ' )|endif
1836+
18301837 let res = s: findamethod (' belongs_to\|has_one\|composed_of\|validates_associated\|scaffold' ,' app/models/\1.rb' )
18311838 if res != " " |return res |endif
1839+
18321840 let res = rails#singularize (s: findamethod (' has_many\|has_and_belongs_to_many' ,' app/models/\1' ))
18331841 if res != " " |return res ." .rb" |endif
1842+
18341843 let res = rails#singularize (s: findamethod (' create_table\|change_table\|drop_table\|add_column\|rename_column\|remove_column\|add_index' ,' app/models/\1' ))
18351844 if res != " " |return res ." .rb" |endif
1845+
18361846 let res = rails#singularize (s: findasymbol (' through' ,' app/models/\1' ))
18371847 if res != " " |return res ." .rb" |endif
1848+
18381849 let res = s: findamethod (' fixtures' ,' fixtures/\1' )
18391850 if res != " "
18401851 return RailsFilePath () = ~ ' \<spec/' ? ' spec/' .res : res
18411852 endif
1853+
18421854 let res = s: findamethod (' map\.resources' ,' app/controllers/\1_controller.rb' )
18431855 if res != " " |return res |endif
1856+
18441857 let res = s: findamethod (' map\.resource' ,' app/controllers/\1' )
18451858 if res != " " |return rails#pluralize (res )." _controller.rb" |endif
1859+
18461860 let res = s: findamethod (' layout' ,' \=s:findlayout(submatch(1))' )
18471861 if res != " " |return res |endif
1862+
18481863 let res = s: findasymbol (' layout' ,' \=s:findlayout(submatch(1))' )
18491864 if res != " " |return res |endif
1865+
18501866 let res = s: findamethod (' helper' ,' app/helpers/\1_helper.rb' )
18511867 if res != " " |return res |endif
1868+
18521869 let res = s: findasymbol (' controller' ,' app/controllers/\1_controller.rb' )
18531870 if res != " " |return res |endif
1871+
18541872 let res = s: findasymbol (' action' ,' \1' )
18551873 if res != " " |return res |endif
1874+
18561875 let res = s: findasymbol (' template' ,' app/views/\1' )
18571876 if res != " " |return res |endif
1877+
18581878 let res = s: sub (s: sub (s: findasymbol (' partial' ,' \1' ),' ^/' ,' ' ),' \k+$' ,' _&' )
18591879 if res != " " |return res ." \n " .s: findview (res )|endif
1880+
18601881 let res = s: sub (s: sub (s: findfromview (' render\s*(\=\s*:partial\s\+=>\s*' ,' \1' ),' ^/' ,' ' ),' \k+$' ,' _&' )
18611882 if res != " " |return res ." \n " .s: findview (res )|endif
1883+
18621884 let res = s: findamethod (' render\s*:\%(template\|action\)\s\+=>\s*' ,' \1.' .format.' \n\1' )
18631885 if res != " " |return res |endif
1886+
18641887 let res = s: sub (s: findfromview (' render' ,' \1' ),' ^/' ,' ' )
18651888 if RailsFileType () = ~ ' ^view\>' | let res = s: sub (res ,' [^/]+$' ,' _&' ) | endif
18661889 if res != " " |return res ." \n " .s: findview (res )|endif
1890+
18671891 let res = s: findamethod (' redirect_to\s*(\=\s*:action\s\+=>\s*' ,' \1' )
18681892 if res != " " |return res |endif
1893+
18691894 let res = s: findfromview (' stylesheet_link_tag' ,' public/stylesheets/\1.css' )
18701895 if res != " " |return res |endif
1896+
18711897 let res = s: sub (s: findfromview (' javascript_include_tag' ,' public/javascripts/\1.js' ),' /defaults>' ,' /application' )
18721898 if res != " " |return res |endif
1899+
18731900 if RailsFileType () = ~ ' ^controller\>'
18741901 let contr = s: controller ()
18751902 let view = s: findit (' \s*\<def\s\+\(\k\+\)\>(\=' ,' /\1' )
18761903 let res = s: findview (contr.' /' .view )
18771904 if res != " " |return res |endif
18781905 endif
1906+
18791907 let old_isfname = &isfname
18801908 try
18811909 set isfname = @ ,48 - 57 ,/,- ,_,: ",\" ,'
0 commit comments