implement g:lightline.component_raw to specify raw type components. (close #240, #134)

Having raw type configuration in component_type is a kind of
implementation design mistake. We sometimes want to specify both the
type and the raw attribute of a component. The raw component feature
shouldn't be included as one of the types of components. Now we can
specify the raw attribute with component_raw and the type with
component_type.
This commit is contained in:
itchyny
2017-08-21 08:21:01 +09:00
parent e7b6c035eb
commit fc7d25e796
3 changed files with 32 additions and 6 deletions

View File

@@ -58,6 +58,19 @@ function! s:suite.raw_type()
delfunction Custom
endfunction
function! s:suite.component_raw()
function! Custom()
return [ ['left'], ['middle'], ['right'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' }, 'component_raw': { 'custom': 1 } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [2], [2], [2], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 2], [2], [2, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.multiple()
function! Custom()
return [ ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'] ]