From a3ce07f6ee1b9b9171ccbfbd5aed3abb1e693945 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 10 Sep 2013 20:42:54 +0900 Subject: [PATCH] improve doc, option to disable tabline/statusline (close #33) --- README.md | 4 ++-- autoload/lightline.vim | 8 +++++--- doc/lightline.txt | 21 ++++++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d3e9869..6dd23f7 100644 --- a/README.md +++ b/README.md @@ -724,7 +724,7 @@ let g:vimfiler_force_overwrite_statusline = 0 let g:vimshell_force_overwrite_statusline = 0 ``` -### Note for other plugins +### Note for developers of other plugins Appearance consistency matters. The statusline is an important space for Vim users. @@ -737,4 +737,4 @@ Firstly, give the users a clue to judge which buffer is the one your plugin crea The filename is a manner and the filetype is another. Then, export a function which is useful to be shown in the statusline. Lastly, for advanced users, set important information in buffer variables. -So that the users can obtain the condition of the plugin freely. +So that the users can obtain the condition of the plugin easily. diff --git a/autoload/lightline.vim b/autoload/lightline.vim index bb141f0..392382c 100644 --- a/autoload/lightline.vim +++ b/autoload/lightline.vim @@ -3,7 +3,7 @@ " Version: 0.0 " Author: itchyny " License: MIT License -" Last Change: 2013/09/08 00:53:10. +" Last Change: 2013/09/10 20:38:31. " ============================================================================= let s:save_cpo = &cpo @@ -13,6 +13,7 @@ let s:_ = 1 function! lightline#update() if s:_ | call lightline#init() | call lightline#colorscheme() | endif + if !s:lightline.enable.statusline | return | endif let s = [lightline#statusline(0), lightline#statusline(1)] let w = winnr() for n in range(1, winnr('$')) @@ -27,7 +28,7 @@ endfunction function! lightline#init() let s:lightline = deepcopy(get(g:, 'lightline', {})) - for k in ['active', 'inactive', 'tabline', 'tab', 'mode_map', 'mode_fallback', + for k in ['active', 'inactive', 'tabline', 'tab', 'mode_map', 'mode_fallback', 'enable', \ 'component', 'component_visible_condition', 'component_function', 'component_expand', 'component_type', \ 'tab_component', 'tab_component_function', 'separator', 'subseparator' ] if !has_key(s:lightline, k) | let s:lightline[k] = {} | endif @@ -69,7 +70,8 @@ function! lightline#init() call extend(s:lightline.separator, { 'left': '', 'right': '' }, 'keep') call extend(s:lightline.subseparator, { 'left': '|', 'right': '|' }, 'keep') call extend(s:lightline, { 'palette': {}, 'colorscheme': 'default' }, 'keep') - set tabline=%!lightline#tabline() + call extend(s:lightline.enable, { 'statusline': 1, 'tabline': 1 }, 'keep') + if s:lightline.enable.tabline | set tabline=%!lightline#tabline() | endif endfunction function! lightline#colorscheme() diff --git a/doc/lightline.txt b/doc/lightline.txt index aacce00..2f103be 100644 --- a/doc/lightline.txt +++ b/doc/lightline.txt @@ -4,7 +4,7 @@ Version: 0.0 Author: itchyny (https://github.com/itchyny) License: MIT License Repository: https://github.com/itchyny/lightline.vim -Last Change: 2013/09/07 16:27:13. +Last Change: 2013/09/10 20:40:34. CONTENTS *lightline-contents* @@ -177,6 +177,8 @@ OPTIONS *lightline-option* g:lightline.tab_component_function *g:lightline.tab_component_function* Another dictionary for components in one tab. + A function specified as a tab component takes one argument: + the tab [count]. The default value is: > let g:lightline.tab_component_function = { @@ -223,12 +225,21 @@ OPTIONS *lightline-option* g:lightline.separator *g:lightline.separator* g:lightline.subseparator *g:lightline.subseparator* - A dictionaries to store separators. + Dictionaries to store separators. The default value is > let g:lightline.separator = { 'left': '', 'right': '' } let g:lightline.subseparator = { 'left': '|', 'right': '|' } < + g:lightline.enable *g:lightline.enable* + A dictionary to specify which feature is turned on. + The default value is +> + let g:lightline.enable = { + \ 'statusline': 1 + \ 'tabline': 1 + \ } +< ============================================================================== FONT *lightline-font* @@ -427,7 +438,7 @@ The type of the syntastic component is error, and the palette has error colors, the result is: > " Expanded result of Example B - (error) [ 'syntastic' ] --- s:p.normal.error[0] = ['gray9', 'brightestred'] + (error) [ syntastic_flag ] --- s:p.normal.error[0] = ['gray9', 'brightestred'] (0) [ 'lineinfo' ] --- s:p.normal.right[0] = ['gray5', 'gray10'] (1) [ 'percent' ] --- s:p.normal.right[1] = ['gray9', 'gray4'] (2) [ 'fileformat', 'fileencoding', 'filetype' ] --- s:p.normal.right[2] = ['gray8', 'gray2'] @@ -466,6 +477,10 @@ then the expanded result is: (tabsel) ['%2T%{lightline#onetab(2,1)}'] --- s:p.tabline.tabsel[0] (0) ['%3T%{lightline#onetab(3,0)}%T', 'C', 'D'] --- s:p.tabline.left[0] < +In summary, when a function in |g:lightline.component_expand| returns an +array of three elements, the first element and the last element remains as a +part of existing component group. And the middle element goes up to new +component group. ============================================================================== EXAMPLES *lightline-examples*