Merge branch 'dev'
This commit is contained in:
commit
c8ef456a25
@ -31,8 +31,18 @@ function! airline#load_theme()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#switch_theme(name)
|
function! airline#switch_theme(name)
|
||||||
|
try
|
||||||
|
let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme
|
||||||
let g:airline_theme = a:name
|
let g:airline_theme = a:name
|
||||||
let palette = g:airline#themes#{g:airline_theme}#palette "also lazy loads the theme
|
catch
|
||||||
|
echohl WarningMsg | echo 'The specified theme cannot be found.' | echohl NONE
|
||||||
|
if exists('g:airline_theme')
|
||||||
|
return
|
||||||
|
else
|
||||||
|
let g:airline_theme = 'dark'
|
||||||
|
let palette = g:airline#themes#dark#palette
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
call airline#themes#patch(palette)
|
call airline#themes#patch(palette)
|
||||||
|
|
||||||
if exists('g:airline_theme_patch_func')
|
if exists('g:airline_theme_patch_func')
|
||||||
|
@ -124,12 +124,13 @@ function! s:get_visible_buffers()
|
|||||||
|
|
||||||
" only show current and surrounding buffers if there are too many buffers
|
" only show current and surrounding buffers if there are too many buffers
|
||||||
let position = index(buffers, cur)
|
let position = index(buffers, cur)
|
||||||
if total_width > winwidth(0) && position > -1
|
let vimwidth = &columns
|
||||||
|
if total_width > vimwidth && position > -1
|
||||||
let buf_count = len(buffers)
|
let buf_count = len(buffers)
|
||||||
|
|
||||||
" determine how many buffers to show based on the longest buffer width,
|
" determine how many buffers to show based on the longest buffer width,
|
||||||
" use one on the right side and put the rest on the left
|
" use one on the right side and put the rest on the left
|
||||||
let buf_max = winwidth(0) / max_width
|
let buf_max = vimwidth / max_width
|
||||||
let buf_right = 1
|
let buf_right = 1
|
||||||
let buf_left = max([0, buf_max - buf_right])
|
let buf_left = max([0, buf_max - buf_right])
|
||||||
|
|
||||||
|
@ -61,6 +61,10 @@ function! airline#init#bootstrap()
|
|||||||
\ 'modified': '+',
|
\ 'modified': '+',
|
||||||
\ 'space': ' ',
|
\ 'space': ' ',
|
||||||
\ }, 'keep')
|
\ }, 'keep')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#init#sections()
|
||||||
|
let g:airline#init#initializing_sections = 1
|
||||||
|
|
||||||
call airline#parts#define('mode', {
|
call airline#parts#define('mode', {
|
||||||
\ 'function': 'airline#parts#mode',
|
\ 'function': 'airline#parts#mode',
|
||||||
@ -77,9 +81,7 @@ function! airline#init#bootstrap()
|
|||||||
call airline#parts#define_raw('linenr', (g:airline_symbols.linenr).'%#__accent_bold#%4l%#__restore__#')
|
call airline#parts#define_raw('linenr', (g:airline_symbols.linenr).'%#__accent_bold#%4l%#__restore__#')
|
||||||
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
|
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
|
||||||
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'whitespace'])
|
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'whitespace'])
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! airline#init#sections()
|
|
||||||
let spc = g:airline_symbols.space
|
let spc = g:airline_symbols.space
|
||||||
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'])
|
||||||
@ -105,5 +107,7 @@ function! airline#init#sections()
|
|||||||
if !exists('g:airline_section_warning')
|
if !exists('g:airline_section_warning')
|
||||||
let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace'])
|
let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace'])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unlet g:airline#init#initializing_sections
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -7,7 +7,11 @@ let s:parts = {}
|
|||||||
|
|
||||||
function! airline#parts#define(key, config)
|
function! airline#parts#define(key, config)
|
||||||
let s:parts[a:key] = get(s:parts, a:key, {})
|
let s:parts[a:key] = get(s:parts, a:key, {})
|
||||||
call extend(s:parts[a:key], a:config)
|
if exists('g:airline#init#initializing_sections')
|
||||||
|
call extend(s:parts[a:key], a:config, 'keep')
|
||||||
|
else
|
||||||
|
call extend(s:parts[a:key], a:config, 'force')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#parts#define_function(key, name)
|
function! airline#parts#define_function(key, name)
|
||||||
|
13
t/init.vim
13
t/init.vim
@ -6,10 +6,11 @@ function! s:clear()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
describe 'init'
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
describe 'init sections'
|
||||||
before
|
before
|
||||||
call s:clear()
|
call s:clear()
|
||||||
call airline#init#bootstrap()
|
|
||||||
call airline#init#sections()
|
call airline#init#sections()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,3 +66,11 @@ describe 'init'
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'init parts'
|
||||||
|
it 'should not redefine parts already defined'
|
||||||
|
call airline#parts#define_raw('linenr', 'bar')
|
||||||
|
call airline#init#sections()
|
||||||
|
Expect g:airline_section_z =~ 'bar'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user