From c2881d8e4fa10d4fca029d3f4d43f007e9171876 Mon Sep 17 00:00:00 2001 From: Bill Niblock Date: Tue, 12 Sep 2017 18:50:41 -0400 Subject: [PATCH] vimrc: Statusline and formatting updates --- vim/vimrc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index b318e7a..9f6eadd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -6,7 +6,9 @@ " General Settings " ============================================================================== set nocompatible " Be IMproved (https://goo.gl/2RiJoo) -syntax on " Syntax hilighting +if !exists('g:syntax_on') + syntax on " Syntax hilighting +endif filetype plugin indent on " Recognize filetype, indent, plugin files set encoding=utf-8 " Character encoding set autoread " Auto-reload files changed outside Vim @@ -47,7 +49,8 @@ augroup END augroup spellcheckr " Spelling, for some files... autocmd! - autocmd BufNewFile,BufRead *.md,*.rdoc,*.txt,*.wiki setlocal spell + autocmd BufNewFile,BufRead *.md,*.rdoc,*.txt,*.wiki + \ setlocal spell augroup END augroup lintr " Simple linting, based on :make! @@ -66,14 +69,15 @@ augroup user_stl_colors " Custom status-line colors \ hi User2 term=bold cterm=bold ctermfg=Cyan ctermbg=DarkGrey | \ hi User3 term=bold cterm=bold ctermfg=White ctermbg=DarkGrey | \ hi User4 ctermfg=White ctermbg=Black | - \ hi User5 ctermfg=150 ctermbg=Black + \ hi User5 ctermfg=150 ctermbg=Black | + \ hi User6 ctermfg=Grey ctermbg=Black augroup END colorscheme minimalist " Set colorscheme " ============================================================================== " Status Line " ============================================================================== -function! GitBranch() " Fetch the Git branch of cwd +function! GitBranch() abort " Fetch the Git branch of cwd let l:branchname = system("git rev-parse --abbrev-ref HEAD 2>/dev/null \ | tr -d '\n'") return strlen(l:branchname) > 0 ? '#'.l:branchname : '' @@ -82,8 +86,8 @@ endfunction set laststatus=2 " Enable the statusline set statusline= " Initialize it set statusline+=%3*%m " Modified flag -set statusline+=%4* " Color change (see :hi) -set statusline+=\ %F " Full-path to current buffer +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 @@ -100,7 +104,7 @@ nnoremap j gj nnoremap k gk nnoremap ^ g^ nnoremap $ g$ -" Toggle fold with space, if we're in a fold, otherwise just space +" Toggle fold with space if we're in a fold, otherwise just space nnoremap @=(foldlevel('.')?'za':"\") vnoremap zf " Allow saving of files as sudo when I forgot to start vim using sudo. @@ -112,7 +116,7 @@ command! -nargs=1 -complete=help H :tabnew | :set buftype=help | :h " Simple mapping to dotfiles directory (f = current tab; F = new tab) nnoremap f :edit ~/.dotfiles/ nnoremap F :tabnew ~/.dotfiles/ -" Emulate vinegar.vim +" Emulate vim-vinegar nnoremap - :silent edit =empty(expand('%')) ? '.' : expand('%:p:h') " ============================================================================== " Plugins