mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-26 10:13:42 +08:00
make it possible to declare sections in the vimrc (#204).
This commit is contained in:
parent
3b2b224a3b
commit
1b91c71fc9
|
@ -7,11 +7,7 @@ function! s:check_defined(variable, default)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:init_vars = 0
|
function! airline#init#bootstrap()
|
||||||
function airline#init#vars()
|
|
||||||
if s:init_vars | return | endif
|
|
||||||
let s:init_vars = 1
|
|
||||||
|
|
||||||
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
||||||
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
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_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
|
||||||
|
@ -55,12 +51,11 @@ function airline#init#vars()
|
||||||
\ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ),
|
\ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ),
|
||||||
\ '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 airline#extensions#load()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#init#bootstrap()
|
function! airline#init#sections()
|
||||||
call airline#init#vars()
|
|
||||||
call airline#extensions#load()
|
|
||||||
|
|
||||||
if !exists('g:airline_section_a')
|
if !exists('g:airline_section_a')
|
||||||
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert'])
|
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert'])
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
" 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
|
||||||
|
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
function! s:get_val(key, append)
|
function! s:get_val(key, append)
|
||||||
let part = airline#parts#get(a:key)
|
let part = airline#parts#get(a:key)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
" 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
|
||||||
|
|
||||||
call airline#init#vars()
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
function! airline#util#wrap(text, minwidth)
|
function! airline#util#wrap(text, minwidth)
|
||||||
if a:minwidth > 0 && winwidth(0) < a:minwidth
|
if a:minwidth > 0 && winwidth(0) < a:minwidth
|
||||||
|
|
|
@ -15,6 +15,7 @@ function! s:init()
|
||||||
let s:airline_initialized = 1
|
let s:airline_initialized = 1
|
||||||
|
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
call airline#init#sections()
|
||||||
|
|
||||||
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()
|
||||||
|
@ -69,7 +70,7 @@ function! s:airline_toggle()
|
||||||
autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter')
|
autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter')
|
||||||
|
|
||||||
autocmd ColorScheme * call <sid>on_colorscheme_changed()
|
autocmd ColorScheme * call <sid>on_colorscheme_changed()
|
||||||
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost,VimResized *
|
autocmd VimEnter,WinEnter,BufWinEnter,FileType,BufUnload,VimResized *
|
||||||
\ call <sid>on_window_changed()
|
\ call <sid>on_window_changed()
|
||||||
|
|
||||||
autocmd BufWritePost */autoload/airline/themes/*.vim
|
autocmd BufWritePost */autoload/airline/themes/*.vim
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
call airline#init#sections()
|
||||||
|
|
||||||
function! MyFuncref(...)
|
function! MyFuncref(...)
|
||||||
call a:1.add_raw('hello world')
|
call a:1.add_raw('hello world')
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
call airline#init#sections()
|
||||||
|
|
||||||
source plugin/airline.vim
|
source plugin/airline.vim
|
||||||
|
|
||||||
describe 'commands'
|
describe 'commands'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
call airline#init#sections()
|
||||||
|
|
||||||
describe 'default'
|
describe 'default'
|
||||||
before
|
before
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe 'init'
|
||||||
before
|
before
|
||||||
call s:clear()
|
call s:clear()
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
call airline#init#sections()
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
|
|
|
@ -33,5 +33,10 @@ describe 'section'
|
||||||
let s = airline#section#create(['hi'])
|
let s = airline#section#create(['hi'])
|
||||||
Expect s == '%#hlgroup#hello'
|
Expect s == '%#hlgroup#hello'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should parse out a section from the vimrc'
|
||||||
|
let s = airline#section#create(['whitespace'])
|
||||||
|
Expect s =~ 'airline#extensions#whitespace#check'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user