Disable airline and enable lightline for status line

This commit is contained in:
Jeremy Gardais 2015-08-21 15:14:55 +02:00
parent 34e2b79763
commit d4aaa38b53
1 changed files with 184 additions and 11 deletions

195
vimrc
View File

@ -228,8 +228,10 @@ Plugin 'rodjek/vim-puppet'
" Auto alignment (for Puppet for example) " Auto alignment (for Puppet for example)
Plugin 'godlygeek/tabular' Plugin 'godlygeek/tabular'
" A pretty statusline " A pretty statusline, bufferline integration
Plugin 'bling/vim-airline' Plugin 'itchyny/lightline.vim'
Plugin 'bling/vim-bufferline'
"Plugin 'bling/vim-airline'
"Bundle 'edkolev/tmuxline.vim' "Bundle 'edkolev/tmuxline.vim'
" Give viual aid to navigate marks " Give viual aid to navigate marks
@ -266,6 +268,20 @@ if has_vundle == 0
":qa ":qa
endif endif
""" User interface {{{
""" Custom highlighting, where NONE uses terminal background {{{
function! CustomHighlighting()
highlight Normal ctermbg=NONE
highlight NonText ctermbg=NONE
highlight LineNr ctermbg=NONE
highlight SignColumn ctermbg=NONE
highlight SignColumn guibg=#151515
highlight CursorLine ctermbg=235
endfunction
call CustomHighlighting()
""" }}}
""" }}}
"########################## "##########################
" SnipMate " SnipMate
@ -380,15 +396,15 @@ let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
"Plugin 'bling/vim-airline' "Plugin 'bling/vim-airline'
" Toujours afficher la barre de statut " Toujours afficher la barre de statut
set laststatus=2 " always show statusline "set laststatus=2 " always show statusline
" Smarter tab line "" Smarter tab line
let g:airline#extensions#tabline#enabled = 1 "let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#left_sep = 'ˇ' ""let g:airline#extensions#tabline#left_sep = 'ˇ'
"let g:airline#extensions#tabline#left_alt_sep = 'v' ""let g:airline#extensions#tabline#left_alt_sep = 'v'
let g:airline_powerline_fonts = 1 "let g:airline_powerline_fonts = 1
"let g:airline_theme='molokai' ""let g:airline_theme='molokai'
"let g:airline_theme='lucius' ""let g:airline_theme='lucius'
let g:airline_theme='monochrome' "let g:airline_theme='monochrome'
"########################## "##########################
" Tmuxline : " Tmuxline :
@ -396,6 +412,163 @@ let g:airline_theme='monochrome'
" https://github.com/edkolev/tmuxline.vim " https://github.com/edkolev/tmuxline.vim
"Plugin 'edkolev/tmuxline.vim' "Plugin 'edkolev/tmuxline.vim'
"##########################
" Lightline :
"##########################
""" Lightline {{{
set laststatus=2 " always show statusline
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'fugitive'],
\ ['ctrlpmark', 'bufferline']
\ ],
\ 'right': [
\ ['lineinfo'],
\ ['percent'],
\ ['fileformat', 'fileencoding', 'filetype', 'syntastic']
\ ]
\ },
\ 'component': {
\ 'paste': '%{&paste?"!":""}'
\ },
\ 'component_function': {
\ 'mode' : 'MyMode',
\ 'fugitive' : 'MyFugitive',
\ 'readonly' : 'MyReadonly',
\ 'ctrlpmark' : 'CtrlPMark',
\ 'bufferline' : 'MyBufferline',
\ 'fileformat' : 'MyFileformat',
\ 'fileencoding' : 'MyFileencoding',
\ 'filetype' : 'MyFiletype'
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'middle',
\ },
\ 'subseparator': {
\ 'left': 'ᑄ', 'right': 'ᑁ'
\ }
\ }
let g:lightline.mode_map = {
\ 'n' : ' Normal ',
\ 'i' : ' Insert ',
\ 'R' : ' Replace ',
\ 'v' : ' Visual ',
\ 'V' : 'Visual-L',
\ 'c' : ' C ',
\ "\<C-v>" : 'Visual-B',
\ 's' : ' Sub ',
\ 'S' : 'Sub-L',
\ "\<C-s>" : 'Sub-B',
\ '?' : ' ' }
function! MyMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
\ winwidth('.') > 60 ? lightline#mode() : ''
endfunction
function! MyFugitive()
try
if expand('%:t') !~? 'Tagbar' && exists('*fugitive#head')
let mark = '± '
let _ = fugitive#head()
return strlen(_) ? mark._ : ''
endif
catch
endtry
return ''
endfunction
function! MyReadonly()
return &ft !~? 'help' && &readonly ? '≠' : '' " or ⭤
endfunction
function! CtrlPMark()
if expand('%:t') =~ 'ControlP'
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
function! MyBufferline()
call bufferline#refresh_status()
let b = g:bufferline_status_info.before
let c = g:bufferline_status_info.current
let a = g:bufferline_status_info.after
let alen = strlen(a)
let blen = strlen(b)
let clen = strlen(c)
let w = winwidth(0) * 4 / 11
if w < alen+blen+clen
let whalf = (w - strlen(c)) / 2
let aa = alen > whalf && blen > whalf ? a[:whalf] : alen + blen < w - clen || alen < whalf ? a : a[:(w - clen - blen)]
let bb = alen > whalf && blen > whalf ? b[-(whalf):] : alen + blen < w - clen || blen < whalf ? b : b[-(w - clen - alen):]
return (strlen(bb) < strlen(b) ? '...' : '') . bb . c . aa . (strlen(aa) < strlen(a) ? '...' : '')
else
return b . c . a
endif
endfunction
function! MyFileformat()
return winwidth('.') > 90 ? &fileformat : ''
endfunction
function! MyFileencoding()
return winwidth('.') > 80 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyFiletype()
return winwidth('.') > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusFunc_2(str)
return lightline#statusline(0)
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
augroup AutoSyntastic
autocmd!
execute "autocmd FileType " .
\join(g:syntastic_mode_map["active_filetypes"], ",") .
\" autocmd BufWritePost <buffer> :call s:syntastic()"
augroup END
""" }}}
"""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""
" Paramétrage de exuberant-ctags " Paramétrage de exuberant-ctags
"http://ngressier.developpez.com/articles/vim/vim-plugin-taglist/#LC "http://ngressier.developpez.com/articles/vim/vim-plugin-taglist/#LC