mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-12 13:33:50 -05:00
improve s:subseparator
- remove duplicated code for component functions - remove parenthesis if unnecessary
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
" Filename: autoload/lightline.vim
|
||||
" Author: itchyny
|
||||
" License: MIT License
|
||||
" Last Change: 2016/04/14 00:16:41.
|
||||
" Last Change: 2016/04/15 00:51:48.
|
||||
" =============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
@@ -345,9 +345,9 @@ endfunction
|
||||
function! s:subseparator(components, subseparator, expanded) abort
|
||||
let [a, c, f, v] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition ]
|
||||
let xs = map(range(len(a:components)), 'a:expanded[v:val] ? "1" :
|
||||
\ has_key(f, a[v:val]) ? (exists("*".f[a[v:val]]) ? "(".f[a[v:val]]."()!=#\"\")" : "(exists(\"*".f[a[v:val]]."\")&&".f[a[v:val]]."()!=#\"\")") :
|
||||
\ has_key(f, a[v:val]) ? (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"" :
|
||||
\ has_key(v, a[v:val]) ? "(" . v[a[v:val]] . ")" : has_key(c, a[v:val]) ? "1" : "0"')
|
||||
return '%{' . (xs[0] !=# '1' ? xs[0] . '&&' : '') . '(' . join(xs[1:], '||') . ')?"' . a:subseparator . '":""}'
|
||||
return '%{' . (xs[0] ==# '1' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' ? '' : ')') . '?"' . a:subseparator . '":""}'
|
||||
endfunction
|
||||
|
||||
function! lightline#concatenate(xs, right) abort
|
||||
|
||||
Reference in New Issue
Block a user