Skip to content

Commit

Permalink
update vim statusline for :term
Browse files Browse the repository at this point in the history
  • Loading branch information
randName committed Mar 29, 2020
1 parent 8d7dac7 commit d61e62e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion vim/plugin/statusline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function! s:FileSize()
endfunction

let s:modetext={
\ 't' : 'Term',
\ '!' : 'Shell',
\ 'c' : 'Command',
\ 'n' : 'Normal',
Expand All @@ -46,6 +47,7 @@ let s:modetext={
\}

let s:modecolor={
\ 't' : 1,
\ '!' : 1,
\ 'c' : 1,
\ 'n' : 4,
Expand All @@ -65,11 +67,15 @@ function! ModeColor()
exec 'hi StatusLine ctermfg=' . l:c
exec 'hi User1 ctermfg=' . l:c

let l:m = get(s:modetext, l:m, '???')
let l:m = get(s:modetext, l:m, mode())
return s:Wide() ? toupper(l:m) : l:m[0]
endfunction

function! DisplayPath()
if &buftype == 'terminal'
return expand('%')[1:]
endif

let l:path = substitute(expand('%:p:h'), $HOME, '~', '')
if s:Wide() < 2
return l:path
Expand All @@ -90,6 +96,10 @@ function! FileInfo()
return l:wide ? 'netrw' : ''
endif

if &buftype == 'terminal'
return l:wide ? 'terminal' : ''
endif

let l:filesize = s:FileSize()
if !l:wide
return l:filesize
Expand Down Expand Up @@ -132,13 +142,17 @@ function! s:SetStatusLine()
let b:statusline=1
endfunction

hi! default link StatusLineTerm StatusLine
hi! default link StatusLineTermNC StatusLineNC

hi User1 ctermbg=10
hi User2 ctermbg=10 ctermfg=7
hi User3 ctermfg=10

augroup statusline
autocmd!
autocmd BufAdd,BufEnter * call s:SetStatusLine()
autocmd TerminalOpen * if &buftype == 'terminal' | setlocal statusline=%!StatusLine(0) | endif
augroup END

let g:loaded_statusline = 1

0 comments on commit d61e62e

Please sign in to comment.