Skip to content

Commit d23ab2f

Browse files
committed
Eliminate custom BufEnter and BufLeave autocommands
1 parent e631f7d commit d23ab2f

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

autoload/rails.vim

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,14 +1254,6 @@ function! s:Refresh(bang)
12541254
endif
12551255
endfunction
12561256

1257-
function! s:RefreshBuffer()
1258-
if exists("b:rails_refresh") && b:rails_refresh
1259-
let b:rails_refresh = 0
1260-
let &filetype = &filetype
1261-
unlet! b:rails_refresh
1262-
endif
1263-
endfunction
1264-
12651257
" }}}1
12661258
" Rake {{{1
12671259

@@ -4013,16 +4005,6 @@ let s:app_prototype.cache = s:cache_prototype
40134005
" }}}1
40144006
" Syntax {{{1
40154007

4016-
function! s:resetomnicomplete()
4017-
if exists("+completefunc") && &completefunc == 'syntaxcomplete#Complete'
4018-
if exists("g:loaded_syntax_completion")
4019-
" Ugly but necessary, until we have our own completion
4020-
unlet g:loaded_syntax_completion
4021-
silent! delfunction syntaxcomplete#Complete
4022-
endif
4023-
endif
4024-
endfunction
4025-
40264008
function! s:app_user_classes() dict
40274009
if self.cache.needs("user_classes")
40284010
let controllers = self.relglob("app/controllers/","**/*",".rb")
@@ -5069,8 +5051,20 @@ endfunction
50695051

50705052
augroup railsPluginAuto
50715053
autocmd!
5072-
autocmd User BufEnterRails call s:RefreshBuffer()
5073-
autocmd User BufEnterRails call s:resetomnicomplete()
5054+
autocmd BufEnter *
5055+
\ if s:active() |
5056+
\ if get(b:, 'rails_refresh') |
5057+
\ let b:rails_refresh = 0 |
5058+
\ let &filetype = &filetype |
5059+
\ unlet! b:rails_refresh |
5060+
\ endif |
5061+
\ if exists("+completefunc") && &completefunc ==# 'syntaxcomplete#Complete' |
5062+
\ if exists("g:loaded_syntax_completion") |
5063+
\ unlet g:loaded_syntax_completion |
5064+
\ silent! delfunction syntaxcomplete#Complete |
5065+
\ endif |
5066+
\ endif |
5067+
\ endif
50745068
autocmd BufWritePost */config/database.yml call rails#cache_clear("db_config")
50755069
autocmd BufWritePost */config/projections.json call rails#cache_clear("projections")
50765070
autocmd BufWritePost */.projections.json call rails#cache_clear("projections")

plugin/rails.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ endfunction
8181

8282
augroup railsPluginDetect
8383
autocmd!
84-
autocmd BufEnter * if exists("b:rails_root")|call s:doau_user('BufEnterRails')|endif
85-
autocmd BufLeave * if exists("b:rails_root")|call s:doau_user('BufLeaveRails')|endif
8684

8785
autocmd BufNewFile,BufReadPost *
8886
\ if RailsDetect(expand("<afile>:p")) && empty(&filetype) |

0 commit comments

Comments
 (0)