mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-22 21:45:06 +02:00
Merge branch 'dynamic' (#164)
This commit is contained in:
commit
4b9cda77dd
@ -26,7 +26,7 @@ function! airline#add_inactive_statusline_func(name)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#load_theme()
|
function! airline#load_theme()
|
||||||
highlight! default link airline_warningmsg WarningMsg
|
highlight! default link airline_warning WarningMsg
|
||||||
call airline#highlighter#load_theme()
|
call airline#highlighter#load_theme()
|
||||||
call airline#extensions#load_theme()
|
call airline#extensions#load_theme()
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -185,14 +185,12 @@ function! airline#extensions#load()
|
|||||||
call airline#extensions#virtualenv#init(s:ext)
|
call airline#extensions#virtualenv#init(s:ext)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:airline_section_warning == '__'
|
if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1))
|
||||||
if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1))
|
call airline#extensions#whitespace#init(s:ext)
|
||||||
call airline#extensions#whitespace#init(s:ext)
|
endif
|
||||||
endif
|
if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1))
|
||||||
if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1))
|
\ && exists(':SyntasticCheck')
|
||||||
\ && exists(':SyntasticCheck')
|
call airline#extensions#syntastic#init(s:ext)
|
||||||
call airline#extensions#syntastic#init(s:ext)
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" load all other extensions not part of the default distribution
|
" load all other extensions not part of the default distribution
|
||||||
|
@ -31,6 +31,6 @@ function! airline#extensions#branch#get_head()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#branch#init(ext)
|
function! airline#extensions#branch#init(ext)
|
||||||
let g:airline_section_b .= '%{airline#extensions#branch#get_head()}'
|
let g:airline_parts.branch = '%{airline#extensions#branch#get_head()}'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -10,7 +10,5 @@ function! airline#extensions#bufferline#init(ext)
|
|||||||
let g:bufferline_active_buffer_right = ''
|
let g:bufferline_active_buffer_right = ''
|
||||||
let g:bufferline_separator = ' '
|
let g:bufferline_separator = ' '
|
||||||
|
|
||||||
if g:airline_section_c == '%f%m'
|
let g:airline_parts.file = '%{bufferline#refresh_status()}'.bufferline#get_status_string()
|
||||||
let g:airline_section_c = '%{bufferline#refresh_status()}'.bufferline#get_status_string()
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -7,6 +7,10 @@ let s:section_truncate_width = get(g:, 'airline#extensions#default#section_trunc
|
|||||||
\ 'y': 88,
|
\ 'y': 88,
|
||||||
\ 'z': 45,
|
\ 'z': 45,
|
||||||
\ })
|
\ })
|
||||||
|
let s:layout = get(g:, 'airline#extensions#default#layout', [
|
||||||
|
\ [ 'a', 'b', 'c' ],
|
||||||
|
\ [ 'x', 'y', 'z', 'warning' ]
|
||||||
|
\ ])
|
||||||
|
|
||||||
function! s:get_section(winnr, key, ...)
|
function! s:get_section(winnr, key, ...)
|
||||||
if has_key(s:section_truncate_width, a:key)
|
if has_key(s:section_truncate_width, a:key)
|
||||||
@ -19,29 +23,34 @@ function! s:get_section(winnr, key, ...)
|
|||||||
return empty(text) ? '' : prefix.text.suffix
|
return empty(text) ? '' : prefix.text.suffix
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:build_sections(builder, keys, winnr)
|
||||||
|
for key in a:keys
|
||||||
|
" i have no idea why the warning section needs special treatment, but it's
|
||||||
|
" needed to prevent separators from showing up
|
||||||
|
if key == 'warning'
|
||||||
|
call a:builder.add_raw('%(')
|
||||||
|
endif
|
||||||
|
call a:builder.add_section('airline_'.key, s:get_section(a:winnr, key))
|
||||||
|
if key == 'warning'
|
||||||
|
call a:builder.add_raw('%)')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#default#apply(builder, context)
|
function! airline#extensions#default#apply(builder, context)
|
||||||
let winnr = a:context.winnr
|
let winnr = a:context.winnr
|
||||||
let active = a:context.active
|
let active = a:context.active
|
||||||
|
|
||||||
if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse))
|
if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse))
|
||||||
call a:builder.add_section('airline_a', s:get_section(winnr, 'a'))
|
call <sid>build_sections(a:builder, s:layout[0], winnr)
|
||||||
call a:builder.add_section('airline_b', s:get_section(winnr, 'b'))
|
|
||||||
call a:builder.add_section('airline_c', '%<'.s:get_section(winnr, 'c'))
|
|
||||||
else
|
else
|
||||||
call a:builder.add_section('airline_c', '%f%m')
|
call a:builder.add_section('airline_a', '%f%m')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call a:builder.split(s:get_section(winnr, 'gutter', '', ''))
|
call a:builder.split(s:get_section(winnr, 'gutter', '', ''))
|
||||||
|
|
||||||
if airline#util#getwinvar(winnr, 'airline_render_right', 1)
|
if airline#util#getwinvar(winnr, 'airline_render_right', 1)
|
||||||
call a:builder.add_section('airline_x', s:get_section(winnr, 'x'))
|
call <sid>build_sections(a:builder, s:layout[1], winnr)
|
||||||
call a:builder.add_section('airline_y', s:get_section(winnr, 'y'))
|
|
||||||
call a:builder.add_section('airline_z', s:get_section(winnr, 'z'))
|
|
||||||
if active
|
|
||||||
call a:builder.add_raw('%(')
|
|
||||||
call a:builder.add_section('airline_warningmsg', s:get_section(winnr, 'warning', '', ''))
|
|
||||||
call a:builder.add_raw('%)')
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
@ -54,6 +54,6 @@ function! airline#extensions#hunks#get_hunks()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#hunks#init(ext)
|
function! airline#extensions#hunks#init(ext)
|
||||||
let g:airline_section_b .= '%{airline#extensions#hunks#get_hunks()}'
|
let g:airline_parts.hunks = '%{airline#extensions#hunks#get_hunks()}'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
function! airline#extensions#syntastic#apply(...)
|
function! airline#extensions#syntastic#get_warnings()
|
||||||
call airline#extensions#append_to_section('warning', '%{SyntasticStatuslineFlag()}')
|
let errors = SyntasticStatuslineFlag()
|
||||||
|
if strlen(errors) > 0
|
||||||
|
return errors.' '
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#syntastic#init(ext)
|
function! airline#extensions#syntastic#init(ext)
|
||||||
call a:ext.add_statusline_func('airline#extensions#syntastic#apply')
|
let g:airline_parts.syntastic = '%{airline#extensions#syntastic#get_warnings()}'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function! airline#extensions#tagbar#init(ext)
|
|||||||
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
|
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
|
||||||
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
|
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
|
||||||
|
|
||||||
let g:airline_section_x = '%(%{get(w:,"airline_active",0) ? tagbar#currenttag("%s","") : ""} '
|
let g:airline_parts.tagbar = '%(%{get(w:,"airline_active",0) ? tagbar#currenttag("%s","") : ""} '
|
||||||
\ .g:airline_right_alt_sep.' %)'.g:airline_section_x
|
\ .g:airline_right_alt_sep.' %)'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ let s:checks = get(g:, 'airline#extensions#whitespace#checks', ['indent', 'trail
|
|||||||
let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]')
|
let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]')
|
||||||
let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]')
|
let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]')
|
||||||
|
|
||||||
let s:initialized = 0
|
|
||||||
let s:enabled = 1
|
let s:enabled = 1
|
||||||
|
|
||||||
function! airline#extensions#whitespace#check()
|
function! airline#extensions#whitespace#check()
|
||||||
@ -39,14 +38,14 @@ function! airline#extensions#whitespace#check()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if trailing != 0 || mixed
|
if trailing != 0 || mixed
|
||||||
let b:airline_whitespace_check = s:symbol." "
|
let b:airline_whitespace_check = s:symbol.' '
|
||||||
if s:show_message
|
if s:show_message
|
||||||
if trailing != 0
|
if trailing != 0
|
||||||
let b:airline_whitespace_check .= printf(s:trailing_format, trailing).' '
|
let b:airline_whitespace_check .= printf(s:trailing_format, trailing)
|
||||||
endif
|
endif
|
||||||
if mixed
|
if mixed
|
||||||
let mixnr = indents[0] == indents[1] ? indents[0] : indents[2]
|
let mixnr = indents[0] == indents[1] ? indents[0] : indents[2]
|
||||||
let b:airline_whitespace_check .= printf(s:mixed_indent_format, mixnr).' '
|
let b:airline_whitespace_check .= printf(s:mixed_indent_format, mixnr)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -54,10 +53,6 @@ function! airline#extensions#whitespace#check()
|
|||||||
return b:airline_whitespace_check
|
return b:airline_whitespace_check
|
||||||
endfunction!
|
endfunction!
|
||||||
|
|
||||||
function! airline#extensions#whitespace#apply(...)
|
|
||||||
call airline#extensions#append_to_section('warning', ' %{airline#extensions#whitespace#check()}')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! airline#extensions#whitespace#toggle()
|
function! airline#extensions#whitespace#toggle()
|
||||||
if s:enabled
|
if s:enabled
|
||||||
autocmd! airline_whitespace CursorHold,BufWritePost
|
autocmd! airline_whitespace CursorHold,BufWritePost
|
||||||
@ -69,10 +64,7 @@ function! airline#extensions#whitespace#toggle()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#whitespace#init(...)
|
function! airline#extensions#whitespace#init(...)
|
||||||
if !s:initialized
|
let g:airline_parts.whitespace = '%{airline#extensions#whitespace#check()}'
|
||||||
let s:initialized = 1
|
|
||||||
call airline#add_statusline_func('airline#extensions#whitespace#apply')
|
|
||||||
endif
|
|
||||||
|
|
||||||
unlet! b:airline_whitespace_check
|
unlet! b:airline_whitespace_check
|
||||||
augroup airline_whitespace
|
augroup airline_whitespace
|
||||||
|
@ -112,7 +112,7 @@ function! s:generate()
|
|||||||
\ [s:N3[0].g, s:N3[1].g, s:N3[0].t, s:N3[1].t, s:N3[2]],
|
\ [s:N3[0].g, s:N3[1].g, s:N3[0].t, s:N3[1].t, s:N3[2]],
|
||||||
\ s:NFa)
|
\ s:NFa)
|
||||||
|
|
||||||
let g:airline#themes#solarized#palette.normal.airline_warningmsg = [
|
let g:airline#themes#solarized#palette.normal.airline_warning = [
|
||||||
\ s:NW[0].g, s:NW[1].g, s:NW[0].t, s:NW[1].t, s:NW[2]]
|
\ s:NW[0].g, s:NW[1].g, s:NW[0].t, s:NW[1].t, s:NW[2]]
|
||||||
|
|
||||||
let g:airline#themes#solarized#palette.normal_modified = {
|
let g:airline#themes#solarized#palette.normal_modified = {
|
||||||
|
@ -44,6 +44,12 @@ call extend(g:airline_parts, {
|
|||||||
\ 'paste': '%{airline#parts#paste()}',
|
\ 'paste': '%{airline#parts#paste()}',
|
||||||
\ 'readonly': '%#airline_file#%{airline#parts#readonly()}',
|
\ 'readonly': '%#airline_file#%{airline#parts#readonly()}',
|
||||||
\ 'ffenc': '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}',
|
\ 'ffenc': '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}',
|
||||||
|
\ 'file': '%f%m',
|
||||||
|
\ 'hunks': '',
|
||||||
|
\ 'branch': '',
|
||||||
|
\ 'tagbar': '',
|
||||||
|
\ 'syntastic': '',
|
||||||
|
\ 'whitespace': '',
|
||||||
\ }, 'keep')
|
\ }, 'keep')
|
||||||
|
|
||||||
call s:check_defined('g:airline_mode_map', {})
|
call s:check_defined('g:airline_mode_map', {})
|
||||||
@ -69,15 +75,6 @@ call extend(g:airline_theme_map, {
|
|||||||
\ '.*solarized.*': 'solarized',
|
\ '.*solarized.*': 'solarized',
|
||||||
\ }, 'keep')
|
\ }, 'keep')
|
||||||
|
|
||||||
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', '')
|
|
||||||
call s:check_defined('g:airline_section_c', '%f%m')
|
|
||||||
call s:check_defined('g:airline_section_gutter', ' '.(g:airline_parts.readonly).'%=')
|
|
||||||
call s:check_defined('g:airline_section_x', '%{&filetype}')
|
|
||||||
call s:check_defined('g:airline_section_y', g:airline_parts.ffenc)
|
|
||||||
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c')
|
|
||||||
call s:check_defined('g:airline_section_warning', '__')
|
|
||||||
|
|
||||||
let s:airline_initialized = 0
|
let s:airline_initialized = 0
|
||||||
let s:airline_theme_defined = 0
|
let s:airline_theme_defined = 0
|
||||||
function! s:init()
|
function! s:init()
|
||||||
@ -85,6 +82,14 @@ function! s:init()
|
|||||||
let s:airline_initialized = 1
|
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_b', (g:airline_parts.hunks).(g:airline_parts.branch))
|
||||||
|
call s:check_defined('g:airline_section_c', '%<'.(g:airline_parts.file))
|
||||||
|
call s:check_defined('g:airline_section_gutter', ' '.(g:airline_parts.readonly).'%=')
|
||||||
|
call s:check_defined('g:airline_section_x', (g:airline_parts.tagbar).'%{&filetype}')
|
||||||
|
call s:check_defined('g:airline_section_y', g:airline_parts.ffenc)
|
||||||
|
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c ')
|
||||||
|
call s:check_defined('g:airline_section_warning', (g:airline_parts.syntastic).(g:airline_parts.whitespace))
|
||||||
|
|
||||||
let s:airline_theme_defined = exists('g:airline_theme')
|
let s:airline_theme_defined = exists('g:airline_theme')
|
||||||
if s:airline_theme_defined || !airline#switch_matching_theme()
|
if s:airline_theme_defined || !airline#switch_matching_theme()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user