mirror of
https://github.com/amix/vimrc
synced 2025-07-04 15:04:59 +08:00
Updated plugins
This commit is contained in:
@ -272,7 +272,7 @@ set noshowmode
|
||||
```
|
||||
|
||||
|
||||
Now, let us get back to the tutorial (with the patched font for vim-powerline).
|
||||
Now, let's get back to the tutorial (with the patched font for vim-powerline).
|
||||
You look into a help file to find the marks annoying.
|
||||
|
||||

|
||||
@ -293,8 +293,8 @@ let g:lightline = {
|
||||

|
||||
|
||||
Huh? Weird!
|
||||
The components do not collapse even if they have no information!
|
||||
In order to avoid this situation, you set expressions to `g:lightline.component_visible_condition`, which should become 1 only when the corresponding components have information.
|
||||
The subseparators are visible even if the components are empty.
|
||||
In order to hide the subseparators, you can set expressions to `g:lightline.component_visible_condition`, which should be 1 only when the corresponding component is not empty.
|
||||
```vim
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'wombat',
|
||||
@ -313,8 +313,8 @@ let g:lightline = {
|
||||

|
||||
|
||||
Okay. It works nice.
|
||||
|
||||
|
||||
The configuration `component_visible_condition` is used to control the visibility of the subseparators.
|
||||
You cannot use this variable to control the visibility of the components themselves.
|
||||
|
||||
How does lightline decide the components to show in the statusline?
|
||||
It's very simple.
|
||||
@ -340,16 +340,9 @@ let g:lightline = {
|
||||
\ }
|
||||
```
|
||||
If the plugin arranges all the components (in a situation you `set paste` and the file `.vimrc` is read-only, try to modify):
|
||||
|
||||

|
||||
|
||||
The mode component, the paste component, read-only component, filename component and modified component in a row.
|
||||
Normally, the paste component does not show up.
|
||||

|
||||
|
||||
If the file is not read-only (more common cases), the read-only component does not show up.
|
||||

|
||||
|
||||
|
||||
Again look into `g:lightline.active.left`.
|
||||
```vim
|
||||
let g:lightline = {
|
||||
@ -357,8 +350,6 @@ let g:lightline = {
|
||||
\ 'left': [ [ 'mode', 'paste' ],
|
||||
\ [ 'readonly', 'filename', 'modified' ] ] ...
|
||||
```
|
||||
And the screen shot of all the components.
|
||||

|
||||
|
||||
The mode and paste component are displayed in the same group.
|
||||
The read-only, filename and modified component are in the second group.
|
||||
@ -369,11 +360,11 @@ You can configure the components in the statusline by the following four variabl
|
||||
+ `g:lightline.inactive.left`
|
||||
+ `g:lightline.inactive.right`
|
||||
|
||||
Of course, your settings in `.vimrc` have priority over the default settings in lightline.
|
||||
Of course, your configurations in `.vimrc` have priority over the default settings in lightline.
|
||||
|
||||
|
||||
|
||||
GitHub branch is important for us.
|
||||
Git branch is important for us.
|
||||
And it is a default component in [powerline](https://github.com/Lokaltog/powerline) and [vim-powerline](https://github.com/Lokaltog/vim-powerline).
|
||||
However, lightline does not provide the branch feature by default.
|
||||
|
||||
@ -552,7 +543,7 @@ subseparator.left | '\|' | '' (\ue0b1) | '⮁' (\u2b81)
|
||||
subseparator.right | '\|' | '' (\ue0b3) | '⮃' (\u2b83)
|
||||
branch symbol | -- | '' (\ue0a0) | '⭠' (\u2b60)
|
||||
readonly symbol | -- | '' (\ue0a2) | '⭤' (\u2b64)
|
||||
linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b81)
|
||||
linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b61)
|
||||
|
||||
### My settings
|
||||
I show my settings. I use the patched font for vim-powerline.
|
||||
|
@ -2,7 +2,7 @@
|
||||
" Filename: autoload/lightline.vim
|
||||
" Author: itchyny
|
||||
" License: MIT License
|
||||
" Last Change: 2016/06/12 22:40:00.
|
||||
" Last Change: 2016/09/04 13:01:40.
|
||||
" =============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
@ -111,6 +111,7 @@ let s:_lightline = {
|
||||
\ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell'
|
||||
\ },
|
||||
\ 'component_function': {},
|
||||
\ 'component_function_visible_condition': {},
|
||||
\ 'component_expand': {
|
||||
\ 'tabs': 'lightline#tabs'
|
||||
\ },
|
||||
@ -293,11 +294,11 @@ function! lightline#highlight(...) abort
|
||||
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 [a, c, f, v, u ] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition, s:lightline.component_function_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]]) ? "" : "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:], '||') . (xs[0] ==# '1' ? '' : ')') . '?"' . a:subseparator . '":""}'
|
||||
\ has_key(f, a[v:val]) ? (has_key(u, a[v:val]) ? "(".u[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] ==# '(1)' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : ')') . '?"' . a:subseparator . '":""}'
|
||||
endfunction
|
||||
|
||||
function! lightline#concatenate(xs, right) abort
|
||||
@ -324,7 +325,7 @@ endfunction
|
||||
|
||||
function! s:evaluate_expand(component) abort
|
||||
try
|
||||
let result = call(a:component, [])
|
||||
let result = eval(a:component . '()')
|
||||
if type(result) == 1 && result ==# ''
|
||||
return []
|
||||
endif
|
||||
|
@ -1,10 +1,10 @@
|
||||
*lightline.txt* A light and configurable statusline/tabline for Vim
|
||||
|
||||
Version: 0.0
|
||||
Version: 0.1
|
||||
Author: itchyny (https://github.com/itchyny)
|
||||
License: MIT License
|
||||
Repository: https://github.com/itchyny/lightline.vim
|
||||
Last Change: 2016/08/09 06:22:39.
|
||||
Last Change: 2016/09/13 23:56:56.
|
||||
|
||||
CONTENTS *lightline-contents*
|
||||
|
||||
@ -19,7 +19,6 @@ Examples |lightline-examples|
|
||||
Nice Examples |lightline-nice-examples|
|
||||
Powerful Example |lightline-powerful-example|
|
||||
Troubleshooting |lightline-troubleshooting|
|
||||
Changelog |lightline-changelog|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *lightline-introduction*
|
||||
@ -115,10 +114,13 @@ OPTIONS *lightline-option*
|
||||
\ 'column': '%c'
|
||||
\ 'close': '%999X X ' }
|
||||
<
|
||||
g:lightline.component_visible_condition *g:lightline.component_visible_condition*
|
||||
Dictionary of boolean expressions for the components.
|
||||
g:lightline.component_visible_condition
|
||||
*g:lightline.component_visible_condition*
|
||||
Dictionary to store the visible condition of the components.
|
||||
Each expression should correspond to the condition each
|
||||
component have non-zero length.
|
||||
component is not empty. This configuration is used to control
|
||||
the visibility of the subseparators. You cannot use this
|
||||
configuration to control the visibility of the components.
|
||||
The default value is:
|
||||
>
|
||||
let g:lightline.component_visible_condition = {
|
||||
@ -135,6 +137,11 @@ OPTIONS *lightline-option*
|
||||
because the user does not have to set both component and
|
||||
component_visible_condition. If a component set to both component and
|
||||
component_function, the setting of component_function has priority.
|
||||
|
||||
The default value is:
|
||||
>
|
||||
let g:lightline.component_function = {}
|
||||
<
|
||||
For example, if you want a component for read-only mark, which
|
||||
disappears in help windows:
|
||||
>
|
||||
@ -150,6 +157,19 @@ OPTIONS *lightline-option*
|
||||
function! LightLineReadonly()
|
||||
return &ft !~? 'help' && &readonly ? 'RO' : ''
|
||||
endfunction
|
||||
<
|
||||
g:lightline.component_function_visible_condition
|
||||
*g:lightline.component_function_visible_condition*
|
||||
Dictionary to store the visible conditions of the function
|
||||
components. Each expression should correspond to the condition
|
||||
each component is not empty. This configuration is used to
|
||||
control the visibility of the subseparators. You can use this
|
||||
configuration to reduce the number of function calls for
|
||||
function components by setting the value 1 (to tell lightline
|
||||
that the component is always visible).
|
||||
The default value is:
|
||||
>
|
||||
let g:lightline.component_function_visible_condition = {}
|
||||
<
|
||||
g:lightline.component_expand *g:lightline.component_expand*
|
||||
Another dictionary for components. You can create a component
|
||||
@ -1126,7 +1146,7 @@ Problem 9: *lightline-problem-9*
|
||||
subseparator.right '|' '' (\ue0b3) '⮃' (\u2b83)
|
||||
branch symbol -- '' (\ue0a0) '⭠' (\u2b60)
|
||||
readonly symbol -- '' (\ue0a2) '⭤' (\u2b64)
|
||||
linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b81)
|
||||
linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b61)
|
||||
|
||||
Problem 10: *lightline-problem-10*
|
||||
Cool statusline disappears on |unite|, |vimfiler| and |vimshell|
|
||||
@ -1270,11 +1290,5 @@ Problem 17: *lightline-problem-17*
|
||||
Report/Request the issue/feature at
|
||||
https://github.com/itchyny/lightline.vim/issues.
|
||||
|
||||
==============================================================================
|
||||
CHANGELOG *lightline-changelog*
|
||||
|
||||
0.0 2013-08-21, ...
|
||||
- Initial commit and implementation
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:sw=4:ts=8:ft=help:norl:noet:
|
||||
|
@ -610,3 +610,15 @@ function! s:suite.duplicated_type_both_nil_right_most()
|
||||
\ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '1']])
|
||||
delfunction Custom
|
||||
endfunction
|
||||
|
||||
function! s:suite.dictionary_function()
|
||||
let g:lightline = { 'component_expand': { 'custom': 'g:lightline.Custom' } }
|
||||
function! g:lightline.Custom()
|
||||
return [ ['left'], ['middle'], ['right'] ]
|
||||
endfunction
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
|
||||
\ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
|
||||
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
|
||||
\ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
|
||||
endfunction
|
||||
|
@ -177,6 +177,111 @@ function! s:suite.subseparator_component_function_7()
|
||||
delfunction Custom3
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_1()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return 'custom2'
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_2()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return 'custom2'
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_3()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return 'custom2'
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_4()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return 'custom2'
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_5()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return ''
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return ''
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_6()
|
||||
function! Custom1()
|
||||
return ''
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return 'custom2'
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom2': '1', 'custom3': '1' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_function_visible_condition_7()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
endfunction
|
||||
function! Custom2()
|
||||
return ''
|
||||
endfunction
|
||||
function! Custom3()
|
||||
return 'custom3'
|
||||
endfunction
|
||||
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom3': '1' } }
|
||||
call lightline#init()
|
||||
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
|
||||
endfunction
|
||||
|
||||
function! s:suite.subseparator_component_expand()
|
||||
function! Custom1()
|
||||
return 'custom1'
|
||||
|
Reference in New Issue
Block a user