Created
June 11, 2014 17:43
-
-
Save 1995eaton/4bc37b5c188514bbe8d6 to your computer and use it in GitHub Desktop.
Vim Powerline
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
function! GetModeName(mode) | |
if a:mode ==# "n" | |
return "NORMAL" | |
elseif a:mode ==# "i" | |
return "INSERT" | |
elseif a:mode ==# "V" | |
return "VISUAL LINE" | |
elseif a:mode ==# "v" | |
return "VISUAL" | |
elseif a:mode ==# "" | |
return "VISUAL BLOCK" | |
elseif a:mode ==# "R" | |
return "REPLACE" | |
endif | |
return a:mode | |
endfunction | |
function! GetStatusColor(mode) | |
if a:mode ==# "INSERT" | |
return [118, 232] | |
elseif a:mode ==# "VISUAL BLOCK" | |
return [161, 253] | |
elseif a:mode ==# "NORMAL" | |
return [81, 232] | |
elseif a:mode ==# "REPLACE" | |
return [118, 232] | |
else | |
return [161, 253] | |
endif | |
endfunction | |
function! SetStatus(mode) | |
if a:mode == "" | |
let l:modecolor = GetStatusColor(GetModeName(mode())) | |
else | |
let l:modecolor = GetStatusColor(a:mode) | |
endif | |
execute 'hi User1 ctermfg=' . l:modecolor[1] . ' ctermbg=' . l:modecolor[0] | |
setlocal statusline=%1* | |
setlocal statusline+=\ | |
setlocal statusline+=%{GetModeName(mode())} | |
execute 'hi User2 ctermbg=238 ctermfg=' . l:modecolor[0] | |
setlocal statusline+=\ %2* | |
hi User3 ctermbg=235 ctermfg=238 | |
hi User4 ctermbg=235 ctermfg=246 | |
setlocal statusline+=%3*\ %4*%f%m%= | |
setlocal statusline+=%3*%2*%1*\ %p%%\ | |
endfunction | |
nnoremap <silent> v :call SetStatus("VISUAL")<CR>v | |
nnoremap <silent> V :call SetStatus("VISUAL LINE")<CR>V | |
nnoremap <silent> <C-v> :call SetStatus("VISUAL BLOCK")<CR><C-v> | |
vnoremap <silent> <Esc> <Esc>:call SetStatus("NORMAL")<CR> | |
vnoremap <silent> <C-[> <C-[>:call SetStatus("NORMAL")<CR> | |
nnoremap <silent> R :call SetStatus("REPLACE")<CR>R | |
au VimEnter,InsertLeave * call SetStatus("NORMAL") | |
au InsertEnter * call SetStatus("INSERT") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment