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

Support mode in statusline

This commit is contained in:
wsdjeg 2017-06-18 23:14:51 +08:00
parent d68d9ce21a
commit bfb2c9e982
2 changed files with 34 additions and 6 deletions

View File

@ -64,9 +64,14 @@ function! s:battery_status() abort
endfunction endfunction
function! s:check_mode() abort function! s:check_mode() abort
if mode() =~ 'n' if mode() == 'n'
elseif mode() =~ 'i' return 'n'
elseif mode() =='i'
return 'i'
elseif mode() =~ 'v' elseif mode() =~ 'v'
return 'v'
elseif mode() =~ 'R'
return 'R'
endif endif
endfunction endfunction
@ -115,7 +120,7 @@ else
endif endif
function! s:winnr() abort function! s:winnr() abort
return ' ' . s:MESSLETTERS.circled_num(winnr(), g:spacevim_windows_index_type) . ' ' return '%{SpaceVim#layers#core#statusline#mode(mode())} ' . s:MESSLETTERS.circled_num(winnr(), g:spacevim_windows_index_type) . ' '
endfunction endfunction
function! s:filename() abort function! s:filename() abort
@ -262,7 +267,8 @@ endfunction
function! SpaceVim#layers#core#statusline#init() abort function! SpaceVim#layers#core#statusline#init() abort
augroup SpaceVim_statusline augroup SpaceVim_statusline
autocmd! autocmd!
autocmd BufWinEnter,WinEnter,FileType * let &l:statusline = SpaceVim#layers#core#statusline#get(1) autocmd BufWinEnter,WinEnter,FileType,InsertEnter,InsertLeave
\ * let &l:statusline = SpaceVim#layers#core#statusline#get(1)
autocmd BufWinLeave,WinLeave * let &l:statusline = SpaceVim#layers#core#statusline#get() autocmd BufWinLeave,WinLeave * let &l:statusline = SpaceVim#layers#core#statusline#get()
autocmd ColorScheme * call SpaceVim#layers#core#statusline#def_colors() autocmd ColorScheme * call SpaceVim#layers#core#statusline#def_colors()
augroup END augroup END
@ -339,3 +345,18 @@ function! SpaceVim#layers#core#statusline#jump(i) abort
exe a:i . 'wincmd w' exe a:i . 'wincmd w'
endif endif
endfunction endfunction
function! SpaceVim#layers#core#statusline#mode(mode)
let t = s:colors_template
if a:mode == 'n'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0]
elseif a:mode == 'i'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0]
elseif a:mode == 'R'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[6][3] . ' ctermfg=' . t[6][2] . ' guibg=' . t[6][1] . ' guifg=' . t[6][0]
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[5][3] . ' ctermfg=' . t[5][2] . ' guibg=' . t[5][1] . ' guifg=' . t[5][0]
endif
call s:HI.hi_separator('SpaceVim_statusline_a', 'SpaceVim_statusline_b')
return ''
endfunction

View File

@ -6,14 +6,21 @@
" \ [ z_guibg, z_ctermbg], " \ [ z_guibg, z_ctermbg],
" \ [ i_guifg, i_guibg, i_ctermfg, i_ctermbg], " \ [ i_guifg, i_guibg, i_ctermfg, i_ctermbg],
" \ [ v_guifg, v_guibg, v_ctermfg, v_ctermbg], " \ [ v_guifg, v_guibg, v_ctermfg, v_ctermbg],
" \ [ r_guifg, r_guibg, r_ctermfg, r_ctermbg],
" \ ] " \ ]
let s:yellow = 'ctermfg=214 guifg=#fabd2f'
let s:blus = 'ctermfg=109 guifg=#83a598'
let s:aqua = 'ctermfg=108 guifg=#8ec07c'
let s:orange = 'ctermfg=208 guifg=#fe8019'
function! SpaceVim#mapping#guide#theme#gruvbox#palette() abort function! SpaceVim#mapping#guide#theme#gruvbox#palette() abort
return [ return [
\ ['#282828', '#a89984', 246, 235], \ ['#282828', '#a89984', 246, 235],
\ ['#a89984', '#504945', 239, 246], \ ['#a89984', '#504945', 239, 246],
\ ['#a89984', '#3c3836', 237, 246], \ ['#a89984', '#3c3836', 237, 246],
\ ['#665c54', 241] \ ['#665c54', 241],
\ ['#282828', '#83a598', 235, 109],
\ ['#282828', '#fe8019', 235, 208],
\ ['#282828', '#8ec07c', 235, 108],
\ ] \ ]
endfunction endfunction