From 7f53b5c3919bde9a4259d0c725d453ef2337a4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Mon, 25 Jun 2012 13:51:44 +0200 Subject: [PATCH] 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. --- plugin/Powerline.vim | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/plugin/Powerline.vim b/plugin/Powerline.vim index 8bab2eb7..5454aa49 100644 --- a/plugin/Powerline.vim +++ b/plugin/Powerline.vim @@ -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 " }}}