1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 20:20:05 +08:00

Add status line

This commit is contained in:
wsdjeg 2017-05-16 22:14:38 +08:00
parent c0fecda644
commit 852d9559ab
4 changed files with 79 additions and 37 deletions

View File

@ -479,6 +479,10 @@ function! SpaceVim#end() abort
silent exec 'lan ' . g:spacevim_language
endif
if index(g:spacevim_plugin_groups, 'core#statusline') != -1
call SpaceVim#layers#core#statusline#init()
endif
if g:spacevim_realtime_leader_guide
nnoremap <silent><nowait> <leader> :<c-u>LeaderGuide get(g:, 'mapleader', '\')<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual get(g:, 'mapleader', '\')<CR>

View File

@ -123,6 +123,14 @@ function! SpaceVim#autocmds#VimEnter() abort
for argv in g:_spacevim_mappings_space_custom
call call('SpaceVim#mapping#space#def', argv)
endfor
if get(g:, '_spacevim_statusline_loaded', 0) == 1
set laststatus=2
set statusline=%!ActiveStatus()
hi User1 guibg=#afd700 guifg=#005f00
hi User2 guibg=#005f00 guifg=#afd700
hi User3 guibg=#222222 guifg=#005f00
hi User4 guibg=#222222 guifg=#d0d0d0
endif
endfunction

View File

@ -1,40 +1,65 @@
let g:spacevim_statusline_mode_format = {
\ 'n' : 'NORMAL',
\ 'i' : 'INSERT',
\ 'v' : 'VISUAL',
\ }
" statusline
let g:_spacevim_statusline_loaded = 1
"""""""""""""""""""""""""""""""""
function! s:mode() abort
let mt = g:spacevim_statusline_mode_format
let m = mode()
return mt[m]
function! ActiveStatus()
let statusline=""
let statusline.="%1*"
let statusline.="%(%{'help'!=&filetype?'\ \ '.bufnr('%'):''}\ %)"
let statusline.="%2*"
let statusline.=""
let statusline.="%{fugitive#head()!=''?'\ \ '.fugitive#head().'\ ':''}"
let statusline.="%3*"
let statusline.=""
let statusline.="%4*"
let statusline.="\ %<"
let statusline.="%f"
let statusline.="%{&modified?'\ \ +':''}"
let statusline.="%{&readonly?'\ \ ':''}"
let statusline.="%="
let statusline.="\ %{''!=#&filetype?&filetype:'none'}"
let statusline.="%(\ %{(&bomb\|\|'^$\|utf-8'!~#&fileencoding?'\ '.&fileencoding.(&bomb?'-bom':''):'').('unix'!=#&fileformat?'\ '.&fileformat:'')}%)"
let statusline.="%(\ \ %{&modifiable?(&expandtab?'et\ ':'noet\ ').&shiftwidth:''}%)"
let statusline.="%3*"
let statusline.="\ "
let statusline.="%2*"
let statusline.=""
let statusline.="%1*"
let statusline.="\ %2v"
let statusline.="\ %3p%%\ "
return statusline
endfunction
function! s:filetype() abort
return &filetype
endfunction
function! s:encoding() abort
return &encoding
function! InactiveStatus()
let statusline=""
let statusline.="%(%{'help'!=&filetype?'\ \ '.bufnr('%').'\ \ ':'\ '}%)"
let statusline.="%{fugitive#head()!=''?'\ \ '.fugitive#head().'\ ':'\ '}"
let statusline.="\ %<"
let statusline.="%f"
let statusline.="%{&modified?'\ \ +':''}"
let statusline.="%{&readonly?'\ \ ':''}"
let statusline.="%="
let statusline.="\ %{''!=#&filetype?&filetype:'none'}"
let statusline.="%(\ %{(&bomb\|\|'^$\|utf-8'!~#&fileencoding?'\ '.&fileencoding.(&bomb?'-bom':''):'').('unix'!=#&fileformat?'\ '.&fileformat:'')}%)"
let statusline.="%(\ \ %{&modifiable?(&expandtab?'et\ ':'noet\ ').&shiftwidth:''}%)"
let statusline.="\ \ "
let statusline.="\ %2v"
let statusline.="\ %3p%%\ "
return statusline
endfunction
function! s:tabname() abort
return '1'
function! SpaceVim#layers#core#statusline#init() abort
augroup status
autocmd!
autocmd WinEnter * setlocal statusline=%!ActiveStatus()
autocmd WinLeave * setlocal statusline=%!InactiveStatus()
autocmd ColorScheme kalisi if(&background=="dark") | hi User1 guibg=#afd700 guifg=#005f00 | endif
autocmd ColorScheme kalisi if(&background=="dark") | hi User2 guibg=#005f00 guifg=#afd700 | endif
autocmd ColorScheme kalisi if(&background=="dark") | hi User3 guibg=#222222 guifg=#005f00 | endif
autocmd ColorScheme kalisi if(&background=="dark") | hi User4 guibg=#222222 guifg=#d0d0d0 | endif
autocmd ColorScheme kalisi if(&background=="light") | hi User1 guibg=#afd700 guifg=#005f00 | endif
autocmd ColorScheme kalisi if(&background=="light") | hi User2 guibg=#005f00 guifg=#afd700 | endif
autocmd ColorScheme kalisi if(&background=="light") | hi User3 guibg=#707070 guifg=#005f00 | endif
autocmd ColorScheme kalisi if(&background=="light") | hi User4 guibg=#707070 guifg=#d0d0d0 | endif
augroup END
endfunction
function! SpaceVim#layers#core#statusline#get() abort
return join([
\ s:mode(),
\ s:tabname(),
\ s:encoding(),
\ s:filetype()
\ ], ' ')
endfunction
function! s:refresh() abort
endfunction
set statusline=%!SpaceVim#layers#core#statusline#get()

View File

@ -1,16 +1,21 @@
scriptencoding utf-8
function! SpaceVim#layers#ui#plugins() abort
return [
let plugins = [
\ ['Yggdroot/indentLine'],
\ ['mhinz/vim-signify'],
\ ['majutsushi/tagbar', {'loadconf' : 1}],
\ ['lvht/tagbar-markdown',{'merged' : 0}],
\ ['t9md/vim-choosewin', {'merged' : 0}],
\ ['vim-airline/vim-airline', { 'merged' : 0,
\ 'loadconf' : 1}],
\ ['vim-airline/vim-airline-themes', { 'merged' : 0}],
\ ['mhinz/vim-startify', {'loadconf' : 1}],
\ ]
if get(g:, '_spacevim_statusline_loaded', 0) == 0
call add(plugins, ['vim-airline/vim-airline', { 'merged' : 0,
\ 'loadconf' : 1}])
call add(plugins, ['vim-airline/vim-airline-themes', { 'merged' : 0}])
endif
return plugins
endfunction
function! SpaceVim#layers#ui#config() abort