@@ -1133,7 +1133,7 @@ endfunction
11331133function ! s: RefreshBuffer ()
11341134 if exists (" b:rails_refresh" ) && b: rails_refresh
11351135 let b: rails_refresh = 0
1136- call rails#buffer_init ()
1136+ call rails#buffer_setup ()
11371137 let &filetype = &filetype
11381138 unlet ! b: rails_refresh
11391139 endif
@@ -1566,7 +1566,7 @@ function! s:Preview(bang, lnum, uri) abort
15661566 setlocal filetype = xhtml
15671567 endif
15681568 endif
1569- call rails#buffer_init ()
1569+ call rails#buffer_setup ()
15701570 map <buffer> <silent> q :bwipe<CR>
15711571 wincmd p
15721572 if ! a: bang
@@ -4431,24 +4431,6 @@ endfunction
44314431" }}}1
44324432" Detection {{{1
44334433
4434- function ! rails#buffer_init ()
4435- let app = rails#app ()
4436- let buffer = rails#buffer ()
4437- " Apparently rails#buffer().calculate_file_type() can be slow if the
4438- " underlying file system is slow (even though it doesn't really do anything
4439- " IO related). This caching is a temporary hack; if it doesn't cause
4440- " problems it should probably be refactored.
4441- let b: rails_cached_file_type = buffer .calculate_file_type ()
4442- call s: BufCommands ()
4443- if ! empty (findfile (' macros/rails.vim' , escape (&runtimepath , ' ' )))
4444- runtime ! macros/rails.vim
4445- endif
4446- silent doautocmd User Rails
4447- call s: BufProjectionCommands ()
4448- call s: BufAbbreviations ()
4449- return b: rails_root
4450- endfunction
4451-
44524434function ! s: SetBasePath () abort
44534435 let self = rails#buffer ()
44544436 if self .app ().path () = ~ ' ://'
@@ -4488,13 +4470,21 @@ function! s:SetBasePath() abort
44884470 call self .setvar (' &path' ,(add_dot ? ' .,' : ' ' ).s: pathjoin (s: uniq (path + [self .app ().path ()] + old_path + engine_paths)))
44894471endfunction
44904472
4491- function ! rails#buffer_settings ()
4473+ function ! rails#buffer_setup () abort
44924474 if ! exists (' b:rails_root' )
44934475 return ' '
44944476 endif
44954477 let self = rails#buffer ()
4496- call s: SetBasePath ()
4478+ let b: rails_cached_file_type = self . calculate_file_type ()
44974479 call s: BufMappings ()
4480+ call s: BufCommands ()
4481+ if ! empty (findfile (' macros/rails.vim' , escape (&runtimepath , ' ' )))
4482+ runtime ! macros/rails.vim
4483+ endif
4484+ silent doautocmd User Rails
4485+ call s: BufProjectionCommands ()
4486+ call s: BufAbbreviations ()
4487+ call s: SetBasePath ()
44984488 let rp = s: gsub (self .app ().path (),' [ ,]' ,' \\&' )
44994489 if stridx (&tags ,rp.' /tags' ) == -1
45004490 let &l: tags = rp . ' /tags,' . rp . ' /tmp/tags,' . &tags
0 commit comments