fixes a weird error after neobundle installs a new plugin.

This commit is contained in:
Bailey Ling 2013-08-28 01:34:10 +00:00
parent 14656f766b
commit eadeee316c

View File

@ -14,20 +14,26 @@ function! s:check_defined(variable, default)
endif endif
endfunction endfunction
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">") let s:airline_initialized = 0
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">") let s:airline_theme_defined = 0
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<") function! s:init()
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<") if !s:airline_initialized
call s:check_defined('g:airline_detect_modified', 1) let s:airline_initialized = 1
call s:check_defined('g:airline_detect_paste', 1)
call s:check_defined('g:airline_detect_iminsert', 0)
call s:check_defined('g:airline_inactive_collapse', 1)
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
call s:check_defined('g:airline_exclude_filetypes', [])
call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_symbols', {}) call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
call extend(g:airline_symbols, { call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
call s:check_defined('g:airline_detect_modified', 1)
call s:check_defined('g:airline_detect_paste', 1)
call s:check_defined('g:airline_detect_iminsert', 0)
call s:check_defined('g:airline_inactive_collapse', 1)
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
call s:check_defined('g:airline_exclude_filetypes', [])
call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_symbols', {})
call extend(g:airline_symbols, {
\ 'paste': get(g:, 'airline_paste_symbol', g:airline_left_alt_sep.' PASTE'), \ 'paste': get(g:, 'airline_paste_symbol', g:airline_left_alt_sep.' PASTE'),
\ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'), \ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'),
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!', \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!',
@ -35,8 +41,8 @@ call extend(g:airline_symbols, {
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''), \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
\ }, 'keep') \ }, 'keep')
call s:check_defined('g:airline_parts', {}) call s:check_defined('g:airline_parts', {})
call extend(g:airline_parts, { call extend(g:airline_parts, {
\ 'mode': '%{get(w:,"airline_current_mode","")}', \ 'mode': '%{get(w:,"airline_current_mode","")}',
\ 'iminsert': '%{airline#parts#iminsert()}', \ 'iminsert': '%{airline#parts#iminsert()}',
\ 'paste': '%{airline#parts#paste()}', \ 'paste': '%{airline#parts#paste()}',
@ -50,8 +56,8 @@ call extend(g:airline_parts, {
\ 'whitespace': '', \ 'whitespace': '',
\ }, 'keep') \ }, 'keep')
call s:check_defined('g:airline_mode_map', {}) call s:check_defined('g:airline_mode_map', {})
call extend(g:airline_mode_map, { call extend(g:airline_mode_map, {
\ '__' : '------', \ '__' : '------',
\ 'n' : 'NORMAL', \ 'n' : 'NORMAL',
\ 'i' : 'INSERT', \ 'i' : 'INSERT',
@ -65,20 +71,14 @@ call extend(g:airline_mode_map, {
\ '' : 'S-BLOCK', \ '' : 'S-BLOCK',
\ }, 'keep') \ }, 'keep')
call s:check_defined('g:airline_theme_map', {}) call s:check_defined('g:airline_theme_map', {})
call extend(g:airline_theme_map, { call extend(g:airline_theme_map, {
\ 'Tomorrow.*': 'tomorrow', \ 'Tomorrow.*': 'tomorrow',
\ 'mo[l|n]okai': 'molokai', \ 'mo[l|n]okai': 'molokai',
\ 'wombat.*': 'wombat', \ 'wombat.*': 'wombat',
\ '.*solarized.*': 'solarized', \ '.*solarized.*': 'solarized',
\ }, 'keep') \ }, 'keep')
let s:airline_initialized = 0
let s:airline_theme_defined = 0
function! s:init()
if !s:airline_initialized
let s:airline_initialized = 1
call airline#extensions#load() call airline#extensions#load()
call s:check_defined('g:airline_section_a', (g:airline_parts.mode).(g:airline_parts.paste).(g:airline_parts.iminsert)) call s:check_defined('g:airline_section_a', (g:airline_parts.mode).(g:airline_parts.paste).(g:airline_parts.iminsert))
call s:check_defined('g:airline_section_b', (g:airline_parts.hunks).(g:airline_parts.branch)) call s:check_defined('g:airline_section_b', (g:airline_parts.hunks).(g:airline_parts.branch))
@ -152,22 +152,22 @@ function! s:airline_toggle()
call <sid>on_window_changed() call <sid>on_window_changed()
endif endif
endif endif
endfunction endfunction
function! s:get_airline_themes(a, l, p) function! s:get_airline_themes(a, l, p)
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n") let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
return map(files, 'fnamemodify(v:val, ":t:r")') return map(files, 'fnamemodify(v:val, ":t:r")')
endfunction endfunction
function! s:airline_theme(...) function! s:airline_theme(...)
if a:0 if a:0
call airline#switch_theme(a:1) call airline#switch_theme(a:1)
else else
echo g:airline_theme echo g:airline_theme
endif endif
endfunction endfunction
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>) command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
command! AirlineToggle call <sid>airline_toggle() command! AirlineToggle call <sid>airline_toggle()
call <sid>airline_toggle() call <sid>airline_toggle()