Add custom statusline in vim

This commit is contained in:
Dave Gallant
2021-02-05 22:56:03 -05:00
parent 7f2028aa7d
commit da274e33de
2 changed files with 28 additions and 4 deletions

View File

@@ -7,7 +7,6 @@
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set mouse=a
set nocompatible
set noswapfile
@@ -21,6 +20,31 @@
set tabstop=2
set wildmenu
" Custom statusline
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
set statusline=
set statusline+=%#PmenuSel#
set statusline+=%{StatuslineGit()}
set statusline+=%#LineNr#
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=%#CursorColumn#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %p%%
set statusline+=\ %l:%c
" Remember line number
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif