dotfiles/vim/vimrc
Bill Niblock bb1eb48bcb Fidgeting
2017-08-15 18:37:22 -04:00

112 lines
5.3 KiB
VimL

" ==============================================================================
" vimrc file for niblock :: Use `:so %` to re-source after changes
" ==============================================================================
" ==============================================================================
" General Settings
" ==============================================================================
set nocompatible " Be IMproved (https://goo.gl/2RiJoo)
syntax on " Syntax hilighting
filetype plugin indent on " Recognize filetype, indent, plugin files
set encoding=utf-8 " Character encoding
set autoread " Auto-reload files changed outside Vim
set hidden " Allow for un-saved buffers
set autoindent " Enable auto-indentation
set expandtab " Use spaces instead of tab characters
set tabstop=4 " How many spaces a tab is
set shiftwidth=4 " How many spaces to shift
set softtabstop=4 " How many spaces to use when editing
colorscheme minimalist " Set colorscheme
set number " Enable line numbers
set wrap " Wrap text
set textwidth=80 " How long a line is
set winwidth=90 " Minimum width of a window
set scrolloff=5 " 5 lines of scroll buffer space
set foldmethod=indent " Enable folding on a syntax level
set foldlevelstart=99 " Don't start with sections folded
set wildmenu " Enable wildmenu
set wildmode:longest:full,full " Configure wildmenu
set ignorecase smartcase " Search: ignore case, unless case matters
set incsearch " Zoom to search results as I type
set nohlsearch " Don't highlight search by default
let g:netrw_liststyle=3 " Netrw Tree list style
let g:netrw_banner=0 " Disable the netrw banner
augroup ruby_settings " Settings for Ruby and Ruby-like langs
autocmd!
autocmd FileType ruby,eruby,yaml
\ setlocal shiftwidth=2
\ softtabstop=2
\ makeprg=rubocop
augroup END
augroup spellcheckr " Spelling, for some files...
autocmd!
autocmd BufNewFile,BufRead *.md,*.rdoc,*.txt,*.wiki setlocal spell
augroup END
augroup lintr " Simple linting, based on :make!
autocmd!
autocmd BufWritePost *.rb,*.sh
\ silent make! <afile> | silent redraw!
autocmd QuickFixCmdPost [^l]* cwindow
augroup END
" ==============================================================================
" Status Line
" ==============================================================================
set laststatus=2 " Enable the statusline
set statusline= " Initialize it
set statusline+=%3*%m%1*%r%0* " Modified, RO, Help flags
set statusline+=%2*%{&spell?'[SPELL]':''} " Spell flag
set statusline+=%3*
" Show the Fugitive-provided status line, if Fugitive is installed
set statusline+=%{exists('g:loaded_fugitive')?fugitive#statusline():''}
set statusline+=%4* " Color change (see :hi)
set statusline+=\ %F " Full-path to current buffer
set statusline+=%= " Switch to right-side
set statusline+=%y\ " Filetype
set statusline+=%3* " Color change (see :hi)
set statusline+=\|%4l\:%2c\| " Line and column
augroup user_stl_colors
autocmd!
autocmd ColorScheme *
\ hi User1 term=bold cterm=bold ctermfg=009 ctermbg=010 |
\ hi User2 term=bold cterm=bold ctermfg=006 ctermbg=010 |
\ hi User3 term=bold cterm=bold ctermfg=015 ctermbg=010 |
\ hi User4 ctermfg=015 ctermbg=016
augroup END
" ==============================================================================
" Mappings
" ==============================================================================
let mapleader = ","
" Make moving up/down work on wrapped lines of text
nnoremap <silent> j gj
nnoremap <silent> k gk
nnoremap <silent> ^ g^
nnoremap <silent> $ g$
" Toggle fold with space, if we're in a fold, otherwise just space
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Remove Trailing Whitespaace
nnoremap <silent> <leader>rtw :%s/\s\+$//e<CR>
" Open help topic in a full new tab
command! -nargs=1 -complete=help H :tabnew | :set buftype=help | :h <args>
" Simple mapping to dotfiles directory (f = current tab; F = new tab)
nnoremap <silent> <leader>f :edit ~/.dotfiles/<CR>
nnoremap <silent> <leader>F :tabnew ~/.dotfiles/<CR>
" Emulate vinegar.vim
nnoremap <silent> - :silent edit <C-R>=empty(expand('%')) ? '.' : expand('%:p:h')<CR><CR>
" ==============================================================================
" Plugins
" ==============================================================================
if filereadable(expand("~/.vimrc-plugins"))
source ~/.vimrc-plugins
endif