Permalink
Browse files

Defer autocmd creation until all plugins are loaded

This update ensures that Powerline's autocmds aren't created until vim
has loaded all plugins and settings, to avoid errors with plugins that
are loaded after Powerline. The VimEnter event is used to accomplish
this.

Closes #152.
Refs majutsushi/tagbar#77.
  • Loading branch information...
1 parent fd3cd90 commit 7f53b5c3919bde9a4259d0c725d453ef2337a4ed @Lokaltog committed Jun 25, 2012
Showing with 19 additions and 11 deletions.
  1. +19 −11 plugin/Powerline.vim
View
@@ -42,20 +42,28 @@
endif
" }}}
" Autocommands {{{
- augroup Powerline
- autocmd!
+ function! s:CreateAutocmds()
+ augroup PowerlineMain
+ autocmd!
+
+ " Reload statuslines when changing color scheme
+ autocmd ColorScheme *
+ \ call Pl#Load()
- " Reload statuslines when changing color scheme
- au ColorScheme *
- \ call Pl#Load()
+ autocmd BufEnter,WinEnter,FileType,BufUnload *
+ \ call Pl#UpdateStatusline(1)
- au BufEnter,WinEnter,FileType,BufUnload *
- \ call Pl#UpdateStatusline(1)
+ autocmd BufLeave,WinLeave *
+ \ call Pl#UpdateStatusline(0)
- au BufLeave,WinLeave *
- \ call Pl#UpdateStatusline(0)
+ autocmd BufWritePost */autoload/Powerline/Colorschemes/*.vim
+ \ :PowerlineReloadColorscheme
+ augroup END
+ endfunction
+
+ augroup PowerlineStartup
+ autocmd!
- au BufWritePost */autoload/Powerline/Colorschemes/*.vim
- \ :PowerlineReloadColorscheme
+ autocmd VimEnter * call s:CreateAutocmds() | call Pl#UpdateStatusline(1)
augroup END
" }}}

0 comments on commit 7f53b5c

Please sign in to comment.