statusline.vim (2732B)
1 let g:currentmode={ 2 \'n' : 'Normal', 3 \'no' : 'N-Operator Pending', 4 \'v' : 'Visual', 5 \'V' : 'V-Line', 6 \'^V' : 'V-Block', 7 \'s' : 'Select', 8 \'S': 'S-Line', 9 \'^S' : 'S-Block', 10 \'i' : 'Insert', 11 \'R' : 'Replace', 12 \'Rv' : 'V-Replace', 13 \'c' : 'Command', 14 \'cv' : 'Vim Ex', 15 \'ce' : 'Ex', 16 \'r' : 'Prompt', 17 \'rm' : 'More', 18 \'r?' : 'Confirm', 19 \'!' : 'Shell', 20 \'t' : 'Terminal' 21 \} 22 23 function! Modecurrent() abort 24 let l:modecurrent = mode() 25 let l:modelist = toupper(get(g:currentmode, l:modecurrent, 'V-Block')) 26 let l:current_status_mode = l:modelist 27 let l:lmode = tolower(l:current_status_mode) 28 29 return l:current_status_mode 30 endfunction 31 32 function! Modecol() 33 let other='' 34 let l:mode=toupper(Modecurrent()) 35 36 if l:mode == 'INSERT' 37 let lcol = 'InsertMode' 38 elseif l:mode == 'COMMAND' 39 let lcol = 'CommandMode' 40 elseif l:mode == 'VISUAL' || l:mode == 'V-BLOCK' || l:mode == 'V-LINE' || l:mode == 'SELECT' 41 let lcol = 'VisualMode' 42 else 43 let lcol = 'NormalMode' 44 endif 45 46 execute 'hi link Modecol ' . lcol 47 return '' 48 endfunction 49 50 function! Gitbranch() 51 return g:system("git branch | tr -d '\n'") 52 endfunction 53 54 function! Activestatus() 55 ""File 56 let g:s.="%#Filecol#" 57 let g:s.=" %f\ -\ %y%m " 58 let g:s.="%#Basecol#" 59 ""Mode 60 let g:s.="%#Modecol#" 61 let g:s.=" %{Modecurrent()}" 62 let g:s.="%#Blankcol#" 63 let g:s.="%=" 64 ""Branch 65 " let g:s.="%#Branchcol#" 66 " let g:s.=" %{Gitbranch()} " 67 " let g:s.="%#Basecol#" 68 ""Position 69 let g:s.="%#Positioncol#" 70 let g:s.=" %l/%L,\ %c " 71 let g:s.="%#Basecol#" 72 73 return g:s 74 endfunction 75 76 function! Inactivestatus() 77 ""File 78 let g:s.="%#Basecol#" 79 let g:s.=" %f\ -\ %y%m" 80 let g:s.="%#Blankcol#" 81 let g:s.="%=" 82 ""Position 83 let g:s.=" %l/%L,\ %c " 84 85 return g:s 86 endfunction 87 88 function! NetrwAstatus() 89 ""Remimder 90 let g:s.="%#Filecol#" 91 let g:s.=" %y " 92 let g:s.="%#Basecol#" 93 94 return g:s 95 endfunction 96 97 function! NetrwIstatus() 98 ""Remimder 99 let g:s.="%#Basecol#" 100 let g:s.=" %y " 101 102 return g:s 103 endfunction 104 105 augroup Statusline 106 autocmd! 107 autocmd FileType netrw let &l:statusline=Choosestatus(1, &filetype) 108 autocmd WinEnter,BufEnter * let &l:statusline=Choosestatus(1, &filetype) 109 autocmd WinNew,BufNew * let &l:statusline=Choosestatus(1, &filetype) 110 autocmd WinLeave,BufLeave * let &l:statusline=Choosestatus(0, &filetype) 111 augroup END 112 113 function! Choosestatus(active, filetype) 114 "Set active or inactive 115 let g:s="%{Modecol()}" 116 if a:active == '1' 117 let statusline=Activestatus() 118 else 119 let statusline=Inactivestatus() 120 endif 121 122 "Overwrite if special 123 if a:filetype == 'netrw' && a:active == '1' 124 let g:s="" 125 let statusline=NetrwAstatus() 126 elseif a:filetype == 'netrw' 127 let g:s="" 128 let statusline=NetrwIstatus() 129 endif 130 131 return statusline 132 endfunction