mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-16 23:43:42 -05:00
s/component_func/component_function/, s/component_flag/component_visible_condition/ (sorry for breaking back conpatibility)
This commit is contained in:
12
README.md
12
README.md
@@ -163,7 +163,7 @@ OK, so you again edit your .vimrc.
|
|||||||

|

|
||||||
Huh? Weird!
|
Huh? Weird!
|
||||||
The component does not collapse even if it has no information!
|
The component does not collapse even if it has no information!
|
||||||
In order to avoid this, you set expressions to component\_flag, which becomes 1 only when the corresponding components have information.
|
In order to avoid this, you set expressions to component\_visible\_condition, which should become 1 only when the corresponding components have information.
|
||||||
```vim
|
```vim
|
||||||
let g:lightline = {
|
let g:lightline = {
|
||||||
\ 'colorscheme': 'wombat',
|
\ 'colorscheme': 'wombat',
|
||||||
@@ -174,7 +174,7 @@ In order to avoid this, you set expressions to component\_flag, which becomes 1
|
|||||||
\ 'readonly': '%{&filetype!="help"&& &readonly?"⭤":""}',
|
\ 'readonly': '%{&filetype!="help"&& &readonly?"⭤":""}',
|
||||||
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
|
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
|
||||||
\ },
|
\ },
|
||||||
\ 'component_flag': {
|
\ 'component_visible_condition': {
|
||||||
\ 'readonly': '(&filetype!="help"&& &readonly)',
|
\ 'readonly': '(&filetype!="help"&& &readonly)',
|
||||||
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
|
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
|
||||||
\ },
|
\ },
|
||||||
@@ -197,7 +197,7 @@ In fact, the components can be created using functions.
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ],
|
\ 'left': [ [ 'mode', 'paste' ],
|
||||||
\ [ 'readonly', 'filename', 'modified' ] ] },
|
\ [ 'readonly', 'filename', 'modified' ] ] },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'readonly': 'MyReadonly',
|
\ 'readonly': 'MyReadonly',
|
||||||
\ 'modified': 'MyModified'
|
\ 'modified': 'MyModified'
|
||||||
\ },
|
\ },
|
||||||
@@ -238,7 +238,7 @@ Now you may know what to do.
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ],
|
\ 'left': [ [ 'mode', 'paste' ],
|
||||||
\ [ 'filename' ] ] },
|
\ [ 'filename' ] ] },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'filename': 'MyFilename',
|
\ 'filename': 'MyFilename',
|
||||||
\ 'readonly': 'MyReadonly',
|
\ 'readonly': 'MyReadonly',
|
||||||
\ 'modified': 'MyModified'
|
\ 'modified': 'MyModified'
|
||||||
@@ -282,7 +282,7 @@ Of course, you can name your component as you wish.
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ],
|
\ 'left': [ [ 'mode', 'paste' ],
|
||||||
\ [ 'my_filename' ] ] },
|
\ [ 'my_filename' ] ] },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'my_filename': 'MyFilename', ...
|
\ 'my_filename': 'MyFilename', ...
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ Here's my setting. I use the patched font for vim-powerline.
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
|
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'modified': 'MyModified',
|
\ 'modified': 'MyModified',
|
||||||
\ 'readonly': 'MyReadonly',
|
\ 'readonly': 'MyReadonly',
|
||||||
\ 'fugitive': 'MyFugitive',
|
\ 'fugitive': 'MyFugitive',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
" Version: 0.0
|
" Version: 0.0
|
||||||
" Author: itchyny
|
" Author: itchyny
|
||||||
" License: MIT License
|
" License: MIT License
|
||||||
" Last Change: 2013/08/22 23:29:52.
|
" Last Change: 2013/08/23 07:32:53.
|
||||||
" =============================================================================
|
" =============================================================================
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
@@ -57,13 +57,13 @@ function! lightline#init()
|
|||||||
\ 'percent': '%3p%%',
|
\ 'percent': '%3p%%',
|
||||||
\ 'lineinfo': '%3l:%-2v',
|
\ 'lineinfo': '%3l:%-2v',
|
||||||
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' }, 'keep')
|
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' }, 'keep')
|
||||||
let g:lightline.component_flag = get(g:lightline, 'component_flag', {})
|
let g:lightline.component_visible_condition = get(g:lightline, 'component_visible_condition', {})
|
||||||
call extend(g:lightline.component_flag, {
|
call extend(g:lightline.component_visible_condition, {
|
||||||
\ 'modified': '(&modified||!&modifiable)',
|
\ 'modified': '(&modified||!&modifiable)',
|
||||||
\ 'readonly': '(&readonly)',
|
\ 'readonly': '(&readonly)',
|
||||||
\ 'paste': '(&paste)',
|
\ 'paste': '(&paste)',
|
||||||
\ 'fugitive': '(exists("*fugitive#head")&&strlen(fugitive#head()))' }, 'keep')
|
\ 'fugitive': '(exists("*fugitive#head")&&strlen(fugitive#head()))' }, 'keep')
|
||||||
let g:lightline.component_func = get(g:lightline, 'component_func', {})
|
let g:lightline.component_function = get(g:lightline, 'component_function', {})
|
||||||
let g:lightline.separator = get(g:lightline, 'separator', {})
|
let g:lightline.separator = get(g:lightline, 'separator', {})
|
||||||
call extend(g:lightline.separator, { 'left': '', 'right': '' }, 'keep')
|
call extend(g:lightline.separator, { 'left': '', 'right': '' }, 'keep')
|
||||||
let g:lightline.subseparator = get(g:lightline, 'subseparator', {})
|
let g:lightline.subseparator = get(g:lightline, 'subseparator', {})
|
||||||
@@ -132,16 +132,14 @@ function! lightline#highlight()
|
|||||||
let [m[2], m[3]] = [s:gui2cui(m[0], m[2]), s:gui2cui(_[1], m[3])]
|
let [m[2], m[3]] = [s:gui2cui(m[0], m[2]), s:gui2cui(_[1], m[3])]
|
||||||
endif
|
endif
|
||||||
for i in range(len(left))
|
for i in range(len(left))
|
||||||
let li = i < len(l) ? l[i] : l[-1]
|
let [li, lj] = [i < len(l) ? l[i] : l[-1], i + 1 < len(l) ? l[i + 1] : l[-1]]
|
||||||
let lj = i + 1 < len(l) ? l[i + 1] : l[-1]
|
|
||||||
exec printf('hi LightLineLeft_%s_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, i, li[0], li[1], li[2], li[3], s:term(li))
|
exec printf('hi LightLineLeft_%s_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, i, li[0], li[1], li[2], li[3], s:term(li))
|
||||||
exec printf('hi LightLineLeft_%s_%d_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d', mode,
|
exec printf('hi LightLineLeft_%s_%d_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d', mode,
|
||||||
\ i, i + 1, li[1], i == len(left) - 1 ? m[1] : lj[1], li[3], i == len(left) - 1 ? m[3] : lj[3])
|
\ i, i + 1, li[1], i == len(left) - 1 ? m[1] : lj[1], li[3], i == len(left) - 1 ? m[3] : lj[3])
|
||||||
endfor
|
endfor
|
||||||
exec printf('hi LightLineMiddle_%s guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, m[0], m[1], m[2], m[3], s:term(m))
|
exec printf('hi LightLineMiddle_%s guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, m[0], m[1], m[2], m[3], s:term(m))
|
||||||
for i in reverse(range(len(right)))
|
for i in reverse(range(len(right)))
|
||||||
let ri = i < len(r) ? r[i] : r[-1]
|
let [ri, rj] = [i < len(r) ? r[i] : r[-1], i + 1 < len(r) ? r[i + 1] : r[-1]]
|
||||||
let rj = i + 1 < len(r) ? r[i + 1] : r[-1]
|
|
||||||
exec printf('hi LightLineRight_%s_%d_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d', mode,
|
exec printf('hi LightLineRight_%s_%d_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d', mode,
|
||||||
\ i, i + 1, ri[1], i == len(right) - 1 ? m[1] : rj[1], ri[3], i == len(right) - 1 ? m[3] : rj[3])
|
\ i, i + 1, ri[1], i == len(right) - 1 ? m[1] : rj[1], ri[3], i == len(right) - 1 ? m[3] : rj[3])
|
||||||
exec printf('hi LightLineRight_%s_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, i, ri[0], ri[1], ri[2], ri[3], s:term(ri))
|
exec printf('hi LightLineRight_%s_%d guifg=%s guibg=%s ctermfg=%d ctermbg=%d %s', mode, i, ri[0], ri[1], ri[2], ri[3], s:term(ri))
|
||||||
@@ -150,20 +148,20 @@ function! lightline#highlight()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! lightline#subseparator(x, y, s)
|
function! lightline#subseparator(x, y, s)
|
||||||
return '%{('.(has_key(g:lightline.component_func,a:x)?'!!strlen('.(g:lightline.component_func[a:x]).'())':get(g:lightline.component_flag,a:x,"1")).')*('.
|
let [c, f, v] = [ g:lightline.component, g:lightline.component_function, g:lightline.component_visible_condition ]
|
||||||
\join(map(copy(a:y),'(has_key(g:lightline.component_func,v:val)?"!!strlen(".g:lightline.component_func[v:val]."())":'.
|
return '%{('.(has_key(f,a:x)?'!!strlen('.(f[a:x]).'())':get(v,a:x,"1")).')*(('.join(map(copy(a:y),
|
||||||
\'get(g:lightline.component_flag,v:val,has_key(g:lightline.component,v:val)?"1":"0"))'),'+').")?('".a:s."'):''}"
|
\'(has_key(f,v:val)?"!!strlen(".f[v:val]."())":get(v,v:val,has_key(c,v:val)?"1":"0"))'),')+(')."))?('".a:s."'):''}"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! lightline#statusline(inactive)
|
function! lightline#statusline(inactive)
|
||||||
let _ = ''
|
let [_, c, f] = [ '', g:lightline.component, g:lightline.component_function ]
|
||||||
let mode = a:inactive ? 'inactive' : 'active'
|
let mode = a:inactive ? 'inactive' : 'active'
|
||||||
let left = has_key(g:lightline, mode) ? g:lightline[mode].left : g:lightline.active.left
|
let left = has_key(g:lightline, mode) ? g:lightline[mode].left : g:lightline.active.left
|
||||||
let right = has_key(g:lightline, mode) ? g:lightline[mode].right : g:lightline.active.right
|
let right = has_key(g:lightline, mode) ? g:lightline[mode].right : g:lightline.active.right
|
||||||
for i in range(len(left))
|
for i in range(len(left))
|
||||||
let _ .= printf('%%#LightLineLeft_%s_%d#', mode, i)
|
let _ .= printf('%%#LightLineLeft_%s_%d#', mode, i)
|
||||||
for j in range(len(left[i]))
|
for j in range(len(left[i]))
|
||||||
let _ .= '%( '.(has_key(g:lightline.component_func,left[i][j])?'%{'.g:lightline.component_func[left[i][j]].'()}':get(g:lightline.component,left[i][j],'')).' %)'
|
let _ .= '%( '.(has_key(f,left[i][j])?'%{'.f[left[i][j]].'()}':get(c,left[i][j],'')).' %)'
|
||||||
if j < len(left[i]) - 1
|
if j < len(left[i]) - 1
|
||||||
let _ .= lightline#subseparator(left[i][j], left[i][j+1:], g:lightline.subseparator.left)
|
let _ .= lightline#subseparator(left[i][j], left[i][j+1:], g:lightline.subseparator.left)
|
||||||
endif
|
endif
|
||||||
@@ -178,7 +176,7 @@ function! lightline#statusline(inactive)
|
|||||||
if j
|
if j
|
||||||
let _ .= lightline#subseparator(right[i][j], right[i][:j-1], g:lightline.subseparator.right)
|
let _ .= lightline#subseparator(right[i][j], right[i][:j-1], g:lightline.subseparator.right)
|
||||||
endif
|
endif
|
||||||
let _ .= '%( '.(has_key(g:lightline.component_func,right[i][j])?'%{'.g:lightline.component_func[right[i][j]].'()}':get(g:lightline.component,right[i][j],'')).' %)'
|
let _ .= '%( '.(has_key(f,right[i][j])?'%{'.f[right[i][j]].'()}':get(c,right[i][j],'')).' %)'
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
return _
|
return _
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Version: 0.0
|
|||||||
Author: itchyny (https://github.com/itchyny)
|
Author: itchyny (https://github.com/itchyny)
|
||||||
License: MIT License
|
License: MIT License
|
||||||
Repository: https://github.com/itchyny/lightline.vim
|
Repository: https://github.com/itchyny/lightline.vim
|
||||||
Last Change: 2013/08/22 22:34:41.
|
Last Change: 2013/08/23 07:11:18.
|
||||||
|
|
||||||
CONTENTS *lightline-contents*
|
CONTENTS *lightline-contents*
|
||||||
|
|
||||||
@@ -60,23 +60,23 @@ OPTIONS *lightline-options*
|
|||||||
\ 'lineinfo': '%3l:%-2v',
|
\ 'lineinfo': '%3l:%-2v',
|
||||||
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' }
|
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' }
|
||||||
<
|
<
|
||||||
g:lightline.component_flag *g:lightline.component_flag*
|
g:lightline.component_visible_condition *g:lightline.component_visible_condition*
|
||||||
Dictionary of boolean expressions for the components.
|
Dictionary of boolean expressions for the components.
|
||||||
Each expression corresponds to if the component have non-zero
|
Each expression should correspond to the condition each
|
||||||
length.
|
component have non-zero length.
|
||||||
For example, the flag for paste component is:
|
For example, the visible condition for paste component is:
|
||||||
>
|
>
|
||||||
let g:lightline.component_flag = {
|
let g:lightline.component_visible_condition = {
|
||||||
\ 'paste': '(&paste)' }
|
\ 'paste': '(&paste)' }
|
||||||
<
|
<
|
||||||
Users are recommended to set this option together with the
|
Users are recommended to set this option together with the
|
||||||
component itself.
|
component itself.
|
||||||
|
|
||||||
g:lightline.component_func *g:lightline.component_func*
|
g:lightline.component_function *g:lightline.component_function*
|
||||||
Another dictionary for components. This is more convenient
|
Another dictionary for components. This is more convenient
|
||||||
because the user does not have to set both component and
|
because the user does not have to set both component and
|
||||||
component_flag. If a component set to both component and
|
component_visible_condition. If a component set to both component and
|
||||||
component_func, the setting of component_func has priority.
|
component_function, the setting of component_function has priority.
|
||||||
For example, if you want a component for read-only mark, which
|
For example, if you want a component for read-only mark, which
|
||||||
disappears in help windows:
|
disappears in help windows:
|
||||||
>
|
>
|
||||||
@@ -85,7 +85,7 @@ OPTIONS *lightline-options*
|
|||||||
\ 'left': [ [ 'mode', 'paste' ],
|
\ 'left': [ [ 'mode', 'paste' ],
|
||||||
\ [ 'myreadonly', 'filename', 'modified' ] ],
|
\ [ 'myreadonly', 'filename', 'modified' ] ],
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'myreadonly': 'MyReadonly'
|
\ 'myreadonly': 'MyReadonly'
|
||||||
\ },
|
\ },
|
||||||
\ }
|
\ }
|
||||||
@@ -134,7 +134,7 @@ nice.
|
|||||||
\ 'component': {
|
\ 'component': {
|
||||||
\ 'lineinfo': ' %3l:%-2v',
|
\ 'lineinfo': ' %3l:%-2v',
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'readonly': 'MyReadonly',
|
\ 'readonly': 'MyReadonly',
|
||||||
\ 'fugitive': 'MyFugitive'
|
\ 'fugitive': 'MyFugitive'
|
||||||
\ },
|
\ },
|
||||||
@@ -155,7 +155,7 @@ look nice.
|
|||||||
\ 'component': {
|
\ 'component': {
|
||||||
\ 'lineinfo': '⭡ %3l:%-2v',
|
\ 'lineinfo': '⭡ %3l:%-2v',
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'readonly': 'MyReadonly',
|
\ 'readonly': 'MyReadonly',
|
||||||
\ 'fugitive': 'MyFugitive'
|
\ 'fugitive': 'MyFugitive'
|
||||||
\ },
|
\ },
|
||||||
@@ -189,7 +189,7 @@ In order to define own component:
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ]
|
\ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ]
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'myfilename': 'MyFilename',
|
\ 'myfilename': 'MyFilename',
|
||||||
\ 'myreadonly': 'MyReadonly',
|
\ 'myreadonly': 'MyReadonly',
|
||||||
\ 'mymodified': 'MyModified',
|
\ 'mymodified': 'MyModified',
|
||||||
@@ -244,7 +244,7 @@ A nice example for |vim-powerline| font users:
|
|||||||
\ 'active': {
|
\ 'active': {
|
||||||
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
|
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
|
||||||
\ },
|
\ },
|
||||||
\ 'component_func': {
|
\ 'component_function': {
|
||||||
\ 'fugitive': 'MyFugitive',
|
\ 'fugitive': 'MyFugitive',
|
||||||
\ 'filename': 'MyFilename'
|
\ 'filename': 'MyFilename'
|
||||||
\ },
|
\ },
|
||||||
|
|||||||
Reference in New Issue
Block a user