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
|
||||
endfunction
|
||||
|
||||
let s:init_vars = 0
|
||||
function airline#init#vars()
|
||||
if s:init_vars | return | endif
|
||||
let s:init_vars = 1
|
||||
|
||||
function! airline#init#bootstrap()
|
||||
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_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) ? '' : ':' ),
|
||||
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
|
||||
\ }, 'keep')
|
||||
|
||||
call airline#extensions#load()
|
||||
endfunction
|
||||
|
||||
function! airline#init#bootstrap()
|
||||
call airline#init#vars()
|
||||
call airline#extensions#load()
|
||||
|
||||
function! airline#init#sections()
|
||||
if !exists('g:airline_section_a')
|
||||
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert'])
|
||||
endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
call airline#init#bootstrap()
|
||||
|
||||
function! s:get_val(key, append)
|
||||
let part = airline#parts#get(a:key)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
call airline#init#vars()
|
||||
call airline#init#bootstrap()
|
||||
|
||||
function! airline#util#wrap(text, minwidth)
|
||||
if a:minwidth > 0 && winwidth(0) < a:minwidth
|
||||
|
|
|
@ -15,6 +15,7 @@ function! s:init()
|
|||
let s:airline_initialized = 1
|
||||
|
||||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
|
||||
let s:airline_theme_defined = exists('g:airline_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 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()
|
||||
|
||||
autocmd BufWritePost */autoload/airline/themes/*.vim
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
|
||||
function! MyFuncref(...)
|
||||
call a:1.add_raw('hello world')
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
|
||||
source plugin/airline.vim
|
||||
|
||||
describe 'commands'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
|
||||
describe 'default'
|
||||
before
|
||||
|
|
|
@ -10,6 +10,7 @@ describe 'init'
|
|||
before
|
||||
call s:clear()
|
||||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
end
|
||||
|
||||
after
|
||||
|
|
|
@ -33,5 +33,10 @@ describe 'section'
|
|||
let s = airline#section#create(['hi'])
|
||||
Expect s == '%#hlgroup#hello'
|
||||
end
|
||||
|
||||
it 'should parse out a section from the vimrc'
|
||||
let s = airline#section#create(['whitespace'])
|
||||
Expect s =~ 'airline#extensions#whitespace#check'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user