diff --git a/vim/vimrc b/vim/vimrc index c72b5e5..da8f059 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -22,6 +22,7 @@ set autoindent " Enable auto-indentation set expandtab " Spaces for tab set shiftwidth=4 " Spaces per shift set softtabstop=4 " Spaces to use when editing +set listchars=tab:>-,trail:ยท " Show me tabs and spaces set number " Enable line numbers set wrap " Wrap text @@ -84,17 +85,42 @@ endif " Status Line " ============================================================================== set laststatus=2 " Enable the statusline -set statusline= " Initialize it -set statusline+=%3*%m " Modified flag -set statusline+=%6*%{expand('%:p:h')}/ " Full-path to current buffer -set statusline+=%4*%t " File name -set statusline+=%5*%{GitBranch()} " Show Git branch, if applicable -set statusline+=%= " Switch to right-side -set statusline+=%4*%y\ " Filetype -set statusline+=%3* " Color change (see :hi) -set statusline+=\|%4l\:%2c\| " Line and column -set statusline+=%2*%{&spell?'[SPELL]':''} " Spell flag -set statusline+=%1*%r%0* " Read-only flag +set statusline=%!ActiveStatus() " Style it + +function! ActiveStatus() abort " When in the active window + let statusline="" " Initialize it + let statusline.="%3*%m" " Modified flag + let statusline.="%6*%{expand('%:p:h')}/" " Full-path to current buffer + let statusline.="%4*%t" " File name + let statusline.="%5*%{GitBranch()}" " Show Git branch, if applicable + let statusline.="%=" " Switch to right-side + let statusline.="%4*%y\ " " Filetype + let statusline.="%3*" " Color change (see :hi) + let statusline.="\|%4l\:%2c\|" " Line and column + let statusline.="%2*%{&spell?'[SPELL]':''}" " Spell flag + let statusline.="%1*%r%0*" " Read-only flag + return statusline +endfunction + +function! PassiveStatus() abort " When in a non-active window + let statusline="" " Initialize it + let statusline.="%6*%m" " Modified flag + let statusline.="%{expand('%:p:h')}/" " Full-path to current buffer + let statusline.="%t" " File name + let statusline.="%{GitBranch()}" " Show Git branch, if applicable + let statusline.="%=" " Switch to right-side + let statusline.="%y\ " " Filetype + let statusline.="\|%4l\:%2c\|" " Line and column + let statusline.="%{&spell?'[SPELL]':''}" " Spell flag + let statusline.="%r%0*" " Read-only flag + return statusline +endfunction + +augroup user_statusline " Change based on active window + autocmd! + autocmd WinEnter * setlocal statusline=%!ActiveStatus() + autocmd WinLeave * setlocal statusline=%!PassiveStatus() +augroup END " ============================================================================== " Mappings " ==============================================================================