From bfb2c9e9827f1c9c3fed88b0b33356382f41f1d4 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 18 Jun 2017 23:14:51 +0800 Subject: [PATCH] Support mode in statusline --- autoload/SpaceVim/layers/core/statusline.vim | 29 ++++++++++++++++--- .../SpaceVim/mapping/guide/theme/gruvbox.vim | 11 +++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 9d62992f9..ac80e156d 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -64,9 +64,14 @@ function! s:battery_status() abort endfunction function! s:check_mode() abort - if mode() =~ 'n' - elseif mode() =~ 'i' + if mode() == 'n' + return 'n' + elseif mode() =='i' + return 'i' elseif mode() =~ 'v' + return 'v' + elseif mode() =~ 'R' + return 'R' endif endfunction @@ -115,7 +120,7 @@ else endif 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 function! s:filename() abort @@ -262,7 +267,8 @@ endfunction function! SpaceVim#layers#core#statusline#init() abort augroup SpaceVim_statusline 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 ColorScheme * call SpaceVim#layers#core#statusline#def_colors() augroup END @@ -339,3 +345,18 @@ function! SpaceVim#layers#core#statusline#jump(i) abort exe a:i . 'wincmd w' endif 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 diff --git a/autoload/SpaceVim/mapping/guide/theme/gruvbox.vim b/autoload/SpaceVim/mapping/guide/theme/gruvbox.vim index 04f27abe5..7f36cb826 100644 --- a/autoload/SpaceVim/mapping/guide/theme/gruvbox.vim +++ b/autoload/SpaceVim/mapping/guide/theme/gruvbox.vim @@ -6,14 +6,21 @@ " \ [ z_guibg, z_ctermbg], " \ [ i_guifg, i_guibg, i_ctermfg, i_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 return [ \ ['#282828', '#a89984', 246, 235], \ ['#a89984', '#504945', 239, 246], \ ['#a89984', '#3c3836', 237, 246], - \ ['#665c54', 241] + \ ['#665c54', 241], + \ ['#282828', '#83a598', 235, 109], + \ ['#282828', '#fe8019', 235, 208], + \ ['#282828', '#8ec07c', 235, 108], \ ] endfunction