Created
March 28, 2016 00:16
-
-
Save actionless/1b00920010aea10c2f13 to your computer and use it in GitHub Desktop.
Vim miniline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" from https://github.com/sd65/MiniVim/blob/master/vimrc | |
" | |
" | |
let g:miniline_left_sep = '' | |
let g:miniline_right_sep = '' | |
"let g:miniline_right_sep = '' | |
"let g:miniline_left_sep = '' | |
let defaultAccentColor=2 | |
let colorsAndModes= { | |
\ 'i' : 3, | |
\ 'v' : 4, | |
\ 'V' : 14, | |
\ '' : 6, | |
\ 'R' : 1, | |
\} | |
function! ReadOnly() | |
return (&readonly || !&modifiable) ? 'Read Only ' : '' | |
endfunction | |
function! Modified() | |
return (&modified) ? '*' : ' ' | |
endfunction | |
let g:currentmode={ | |
\ 'n' : 'Normal', | |
\ 'no' : 'N·Operator Pending', | |
\ 'v' : 'Visual', | |
\ 'V' : 'V·Line', | |
\ '' : 'V·Block', | |
\ 's' : 'Select', | |
\ 'S' : 'S·Line', | |
\ '^S' : 'S·Block', | |
\ 'i' : 'Insert', | |
\ 'R' : 'Replace', | |
\ 'Rv' : 'VReplace', | |
\ 'c' : 'Command', | |
\ 'cv' : 'Vim Ex', | |
\ 'ce' : 'Ex', | |
\ 'r' : 'Prompt', | |
\ 'rm' : 'More', | |
\ 'r?' : 'Confirm', | |
\ '!' : 'Shell', | |
\ 't' : 'Terminal', | |
\} | |
function! SetStatusLine() | |
set statusline= | |
"set statusline+=%{ChangeAccentColor()} | |
set statusline+=%2*%{g:miniline_left_sep} | |
set statusline+=%1*%{Modified()}%{toupper(g:currentmode[mode()])}%{Modified()}" Current mode | |
set statusline+=%2*%{g:miniline_right_sep}\ %<%F\ " Filepath | |
set statusline+=%2*\ %= " To the right | |
set statusline+=%2*\ %{toupper((&fenc!=''?&fenc:&enc))}\[%{&ff}] " Encoding & Fileformat | |
set statusline+=%2*\ %{ReadOnly()}%{g:miniline_left_sep} " Flags | |
set statusline+=%1*\%l/%L-%c " Position | |
set statusline+=%2*%{g:miniline_right_sep} | |
endfunction | |
call SetStatusLine() | |
function! ChangeAccentColor() | |
echo 'debug' . mode() | |
let accentColor=get(g:colorsAndModes, mode(), g:defaultAccentColor) | |
execute 'hi User1 ctermfg=0 ctermbg=' . accentColor | |
execute 'hi User2 ctermbg=0 ctermfg=' . accentColor | |
execute 'hi User3 ctermfg=0 cterm=bold ctermbg=' . accentColor | |
execute 'hi TabLineSel ctermfg=0 cterm=bold ctermbg=' . accentColor | |
execute 'hi TabLine ctermbg=0 ctermfg=' . accentColor | |
execute 'hi CursorLineNr ctermfg=' . accentColor | |
call SetStatusLine() | |
echo 'debug' . mode() . 'done' | |
return '' | |
endfunction | |
au InsertLeave * call ChangeAccentColor() | |
au InsertEnter * call ChangeAccentColor() | |
vnoremap <expr> <SID>CursorLineNrColorVisual ChangeAccentColor() | |
nnoremap <script> v v<SID>ChangeAccentColor | |
nnoremap <script> V V<SID>ChangeAccentColor | |
nnoremap <script> <C-v> <C-v><SID>ChangeAccentColor | |
call ChangeAccentColor() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment