dotfiles/vim/vimrc

116 lines
5.5 KiB
VimL
Raw Normal View History

2017-02-22 01:16:16 +00:00
" ==============================================================================
" 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
2017-08-15 13:41:19 +00:00
set hidden " Allow for un-saved buffers
2017-02-22 01:16:16 +00:00
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
2017-08-15 13:41:19 +00:00
set number " Enable line numbers
set wrap " Wrap text
2017-02-22 01:16:16 +00:00
set textwidth=80 " How long a line is
2017-07-05 18:42:58 +00:00
set winwidth=90 " Minimum width of a window
2017-08-15 13:41:19 +00:00
set scrolloff=5 " 5 lines of scroll buffer space
2017-02-22 01:16:16 +00:00
2017-08-15 13:41:19 +00:00
set foldmethod=indent " Enable folding on a syntax level
set foldlevelstart=99 " Don't start with sections folded
2017-02-22 01:16:16 +00:00
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
2017-08-15 13:41:19 +00:00
set nohlsearch " Don't highlight search by default
2017-02-22 01:16:16 +00:00
let g:netrw_liststyle=3 " Netrw Tree list style
2017-08-15 22:37:22 +00:00
let g:netrw_banner=0 " Disable the netrw banner
2017-02-22 01:16:16 +00:00
augroup ruby_settings " Settings for Ruby and Ruby-like langs
2016-10-09 00:02:14 +00:00
autocmd!
2017-08-15 13:41:19 +00:00
autocmd FileType ruby,eruby,yaml
\ setlocal shiftwidth=2
\ softtabstop=2
2017-08-15 22:37:22 +00:00
\ makeprg=rubocop
2016-10-09 00:02:14 +00:00
augroup END
2015-04-11 20:14:53 +00:00
2017-02-22 01:16:16 +00:00
augroup spellcheckr " Spelling, for some files...
autocmd!
autocmd BufNewFile,BufRead *.md,*.rdoc,*.txt,*.wiki setlocal spell
2017-01-28 01:52:36 +00:00
augroup END
augroup lintr " Simple linting, based on :make!
autocmd!
2017-08-15 13:41:19 +00:00
autocmd BufWritePost *.rb,*.sh
\ silent make! <afile> | silent redraw!
autocmd QuickFixCmdPost [^l]* cwindow
augroup END
" ==============================================================================
2017-08-16 23:53:05 +00:00
" Colors
" ==============================================================================
augroup user_stl_colors " Custom status-line 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
colorscheme minimalist " Set colorscheme
" ==============================================================================
" Status Line
" ==============================================================================
2017-05-23 03:57:51 +00:00
set laststatus=2 " Enable the statusline
set statusline= " Initialize it
2017-08-16 23:53:05 +00:00
set statusline+=%3*%m " Modified flag
" Show the Fugitive-provided status line, if Fugitive is installed
set statusline+=%{exists('g:loaded_fugitive')?fugitive#statusline():''}
2017-08-15 13:41:19 +00:00
set statusline+=%4* " Color change (see :hi)
2017-05-23 03:57:51 +00:00
set statusline+=\ %F " Full-path to current buffer
set statusline+=%= " Switch to right-side
set statusline+=%y\ " Filetype
2017-08-15 13:41:19 +00:00
set statusline+=%3* " Color change (see :hi)
2017-05-23 03:57:51 +00:00
set statusline+=\|%4l\:%2c\| " Line and column
2017-08-16 23:53:05 +00:00
set statusline+=%2*%{&spell?'[SPELL]':''} " Spell flag
set statusline+=%1*%r%0* " Read-only flag
2017-02-22 01:16:16 +00:00
" ==============================================================================
" Mappings
" ==============================================================================
let mapleader = ","
2016-08-20 23:51:09 +00:00
" Make moving up/down work on wrapped lines of text
nnoremap <silent> j gj
nnoremap <silent> k gk
nnoremap <silent> ^ g^
nnoremap <silent> $ g$
2017-02-22 01:16:16 +00:00
" Toggle fold with space, if we're in a fold, otherwise just space
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
2015-05-24 19:40:04 +00:00
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
2015-11-06 22:55:09 +00:00
" Remove Trailing Whitespaace
nnoremap <silent> <leader>rtw :%s/\s\+$//e<CR>
" Open help topic in a full new tab
2017-01-28 01:52:36 +00:00
command! -nargs=1 -complete=help H :tabnew | :set buftype=help | :h <args>
2017-05-26 21:49:22 +00:00
" 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>
2017-08-15 13:41:19 +00:00
" Emulate vinegar.vim
nnoremap <silent> - :silent edit <C-R>=empty(expand('%')) ? '.' : expand('%:p:h')<CR><CR>
2017-02-22 01:16:16 +00:00
" ==============================================================================
" Plugins
" ==============================================================================
if filereadable(expand("~/.vimrc-plugins"))
source ~/.vimrc-plugins
endif