mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-15 06:53:51 -05:00
implement lightline#enable(), lightline#disable(), lightline#toggle() (close #49)
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
" Version: 0.0
|
" Version: 0.0
|
||||||
" Author: itchyny
|
" Author: itchyny
|
||||||
" License: MIT License
|
" License: MIT License
|
||||||
" Last Change: 2013/12/04 08:40:56.
|
" Last Change: 2013/12/05 13:11:43.
|
||||||
" =============================================================================
|
" =============================================================================
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
@@ -26,6 +26,49 @@ function! lightline#update_once()
|
|||||||
if !exists('w:lightline') || w:lightline | call lightline#update() | endif
|
if !exists('w:lightline') || w:lightline | call lightline#update() | endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! lightline#update_disable()
|
||||||
|
if !s:lightline.enable.statusline | return | endif
|
||||||
|
call setwinvar(1, '&statusline', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! lightline#enable()
|
||||||
|
call lightline#colorscheme()
|
||||||
|
call lightline#update()
|
||||||
|
if s:lightline.enable.tabline | set tabline=%!lightline#tabline() | endif
|
||||||
|
augroup LightLine
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter,BufWinEnter,FileType,ColorScheme * call lightline#update()
|
||||||
|
autocmd ColorScheme,SessionLoadPost * call lightline#highlight()
|
||||||
|
autocmd CursorMoved,BufUnload * call lightline#update_once()
|
||||||
|
augroup END
|
||||||
|
augroup LightLineDisable
|
||||||
|
autocmd!
|
||||||
|
augroup END
|
||||||
|
augroup! LightLineDisable
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! lightline#disable()
|
||||||
|
let [&statusline, &tabline] = [get(s:, '_statusline', ''), get(s:, '_tabline', '')]
|
||||||
|
for t in range(1, tabpagenr('$'))
|
||||||
|
for n in range(1, tabpagewinnr(t, '$'))
|
||||||
|
call settabwinvar(t, n, '&statusline', '')
|
||||||
|
call settabwinvar(t, n, 'lightline', 0)
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
augroup LightLine
|
||||||
|
autocmd!
|
||||||
|
augroup END
|
||||||
|
augroup! LightLine
|
||||||
|
augroup LightLineDisable
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter * call lightline#update_disable()
|
||||||
|
augroup END
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! lightline#toggle()
|
||||||
|
if exists('#LightLine') | call lightline#disable() | else | call lightline#enable() | endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! lightline#init()
|
function! lightline#init()
|
||||||
let s:lightline = deepcopy(get(g:, 'lightline', {}))
|
let s:lightline = deepcopy(get(g:, 'lightline', {}))
|
||||||
for k in ['active', 'inactive', 'tabline', 'tab', 'mode_map', 'mode_fallback', 'enable',
|
for k in ['active', 'inactive', 'tabline', 'tab', 'mode_map', 'mode_fallback', 'enable',
|
||||||
@@ -73,6 +116,8 @@ function! lightline#init()
|
|||||||
call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep')
|
call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep')
|
||||||
call extend(s:lightline, { 'palette': {}, 'colorscheme': 'default' }, 'keep')
|
call extend(s:lightline, { 'palette': {}, 'colorscheme': 'default' }, 'keep')
|
||||||
call extend(s:lightline.enable, { 'statusline': 1, 'tabline': 1 }, 'keep')
|
call extend(s:lightline.enable, { 'statusline': 1, 'tabline': 1 }, 'keep')
|
||||||
|
if !exists('s:_statusline') | let s:_statusline = &statusline | endif
|
||||||
|
if !exists('s:_tabline') | let s:_tabline = &tabline | endif
|
||||||
if s:lightline.enable.tabline | set tabline=%!lightline#tabline() | endif
|
if s:lightline.enable.tabline | set tabline=%!lightline#tabline() | endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -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/10/20 19:16:34.
|
Last Change: 2013/12/04 18:17:07.
|
||||||
|
|
||||||
CONTENTS *lightline-contents*
|
CONTENTS *lightline-contents*
|
||||||
|
|
||||||
@@ -346,6 +346,15 @@ Exposed functions for lightline.vim.
|
|||||||
lightline#update_once() *lightline#update_once()*
|
lightline#update_once() *lightline#update_once()*
|
||||||
Updates the statuslines only once.
|
Updates the statuslines only once.
|
||||||
|
|
||||||
|
lightline#enable() *lightline#enable()*
|
||||||
|
Enables |lightline|.
|
||||||
|
|
||||||
|
lightline#disable() *lightline#disable()*
|
||||||
|
Disables |lightline|.
|
||||||
|
|
||||||
|
lightline#toggle() *lightline#toggle()*
|
||||||
|
Toggles |lightline|.
|
||||||
|
|
||||||
lightline#link([mode]) *lightline#link()*
|
lightline#link([mode]) *lightline#link()*
|
||||||
Creates links of the highlight groups for the active window.
|
Creates links of the highlight groups for the active window.
|
||||||
This function accepts an optional argument. It should be one
|
This function accepts an optional argument. It should be one
|
||||||
|
|||||||
Reference in New Issue
Block a user