dotfiles/vimrc

265 lines
7.2 KiB
VimL
Raw Normal View History

2013-09-05 11:49:24 -04:00
" Fix for CSE servers
scriptencoding utf-8
set encoding=utf-8
2014-05-08 23:47:44 -04:00
" vundle bundle; not for changing
set nocompatible " Disable vi compatibility
filetype off
set runtimepath+=~/.vim/bundle/vundle/
2014-05-08 23:47:44 -04:00
call vundle#begin()
2013-04-29 15:29:20 -04:00
2015-12-10 10:42:05 -05:00
Plugin 'gmarik/vundle'
Plugin 'airblade/vim-gitgutter'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'godlygeek/tabular'
Plugin 'itchyny/lightline.vim'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'rodjek/vim-puppet'
2015-12-11 08:46:13 -05:00
Plugin 'thoughtbot/vim-rspec'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-endwise'
2015-12-10 10:42:05 -05:00
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-vividchalk'
2015-12-11 08:46:13 -05:00
Plugin 'vim-ruby/vim-ruby'
2013-04-29 15:29:20 -04:00
2014-05-08 23:47:44 -04:00
call vundle#end()
filetype plugin indent on
" end vundle
2013-04-29 02:31:18 -04:00
" Options
2013-07-20 00:08:00 -04:00
set fileformats=unix,dos " File format prefer unix endings
set endofline " Add newlien at end of file
set shellslash " Forward slashes
set nobackup " No backup files
set formatoptions=crq
2013-04-29 02:31:18 -04:00
set textwidth=80
set cpoptions+=$ " delimit end of change text
2013-07-20 00:08:00 -04:00
set laststatus=2 " Always show status line
set showmode " Show current mode
set history=100 " History length
set cursorline " Highlight current line
2013-07-24 23:06:54 -04:00
set cursorcolumn " Highlight current column
2013-07-20 00:08:00 -04:00
set nowrap " Disable wrapping by default
set backspace=2 " Backspace over indent, eol, start of insert
set hlsearch " Search highlights
set wrapscan " Wraped search
set incsearch " Search as yuo type
set ignorecase " Ignore case with search
set smartcase " Search will not ignore uppercase
set showcmd " Show command as you type
set ruler " Show cursor position
2013-04-29 02:31:18 -04:00
set autoindent
2013-07-20 00:08:00 -04:00
set colorcolumn=80 " Ruler at line 80
set nomodeline
2013-07-20 00:08:00 -04:00
set relativenumber " Relative line numbers
set number
2013-07-20 00:08:00 -04:00
set noswapfile " Hope for the best
2013-08-12 02:18:47 -04:00
set virtualedit=all " Cursor can go anywhere
set scrolloff=3 " Keep cursor from touching edges
2014-05-08 23:47:44 -04:00
set timeoutlen=500 " Don't wait too long (ambiguous leaders)
set showmatch " Show matching brackets
set hidden " Allow unsaved buffers to be hidden
set wildmenu " Command line completion
2014-12-18 10:17:11 -05:00
set wildignorecase " Ignore case on commandline
" Make syntax highlighting faster
syntax sync minlines=256
set ttyfast
set lazyredraw
2013-04-29 02:31:18 -04:00
" Tabs are 2 spaces
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
2014-05-08 23:47:44 -04:00
set shiftround " if at odd number spaces, make >> go to next even
2013-08-05 21:38:24 -04:00
" Show whitespace markers before cursor in insert mode
set list listchars=tab:\ \ ,trail
2014-12-12 12:59:19 -05:00
" Ignore stuff
set wildignore+=*/\.git/*
" Java
2014-12-12 13:51:31 -05:00
set wildignore+=*/build/*,*/grade/*,*\.class
2014-12-12 12:59:19 -05:00
" Frontend
set wildignore+=*/node_modules/*,*/bower_components/*,*/dist/*
2013-04-29 13:32:51 -04:00
" Filetype stuff
2013-04-29 15:29:20 -04:00
syntax on
2013-04-29 13:32:51 -04:00
" Keybinds
" ctrl+s for save spam
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
2014-05-11 02:48:01 -04:00
" most common typo ever
command! Q q
2014-12-18 16:39:40 -05:00
" consistency is key - Y should act like C, D
map Y y$
2013-08-05 22:07:01 -04:00
" Still using arrow keys when in insert mode sometimes
2014-05-09 01:15:48 -04:00
map <Left> <NOP>
map <Right> <NOP>
map <Up> <NOP>
map <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
2013-08-05 22:07:01 -04:00
2013-10-01 14:36:44 -04:00
" Don't cancel visual mode while indenting
vnoremap > >gv
vnoremap < <gv
2014-05-09 01:16:01 -04:00
" Use better search highlighting
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
2014-05-11 02:48:01 -04:00
" i don't even know what semi-colon does so steal it
noremap ; :
2014-05-08 23:47:44 -04:00
" Leaders (shortcuts)
2013-04-29 13:32:51 -04:00
let mapleader = ","
2013-10-01 14:36:44 -04:00
" tab swaps
2013-09-20 11:05:47 -04:00
map <Leader>2 :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab<cr>
map <Leader>4 :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab<cr>
map <Leader>a :set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab<cr>
2013-10-01 14:36:44 -04:00
" buffer movement
map <Leader>h :wincmd h<cr>
map <Leader>j :wincmd j<cr>
map <Leader>k :wincmd k<cr>
map <Leader>l :wincmd l<cr>
2013-10-14 00:19:08 -04:00
" auto character alignment
map <Leader>t> :Tabularize /=><cr>
map <Leader>te :Tabularize /=<cr>
" vundle
2015-12-10 10:42:05 -05:00
map <Leader>bi :PluginInstall<cr>
map <Leader>bu :PluginInstall!<cr>
2013-10-14 00:19:08 -04:00
" copy and paste - for Linux
2013-08-08 14:07:23 -04:00
map <Leader>c "+
2013-10-14 00:19:08 -04:00
map <Leader>p "+p
map <Leader>pm :set paste!<cr>
2014-05-08 23:47:44 -04:00
" clear search
2013-10-01 14:36:44 -04:00
map <Leader>cs :let @/ = ""<cr>
2013-10-14 00:19:08 -04:00
" indent and return
map <Leader>i mmgg=G`m<cr>
2013-10-14 00:19:08 -04:00
" reload all buffers
2013-10-01 14:36:44 -04:00
map <Leader>ra :bufdo e!<cr>
2014-05-08 23:47:44 -04:00
" this was better when it was :Sexplore...
map <Leader>s :Vexplore ~/Source/<cr>
2015-02-21 20:33:40 -05:00
map <Leader>d :Vexplore .<cr>
2014-05-08 23:47:44 -04:00
map <Leader>fw :FixWhitespace<cr>
map <Leader>lf :call LargeFileToggle()<cr>
2013-08-05 22:07:01 -04:00
map <Leader>sa :call RenameFile()<cr>
2013-07-19 01:39:58 -04:00
map <Leader>se :e ~/.vimrc<cr>
2013-10-01 14:36:44 -04:00
map <Leader>st :call SyntaxToggle()<cr>
2013-07-19 01:39:58 -04:00
map <Leader>sz :so ~/.vimrc<cr>
map <Leader>ts :sp ~/tool-sharpener.txt<cr>
2013-04-29 13:32:51 -04:00
2015-12-11 08:46:13 -05:00
" rspec
map <Leader>t :w<cr>:call RunNearestSpec()<cr>
2013-04-29 13:32:51 -04:00
" Set style
colorscheme vividchalk
2013-10-01 14:36:44 -04:00
" special case colors set at end of file via function
2015-12-11 08:46:13 -05:00
" dispatch fix for bundle exec rspec always quickfixing
let g:dispatch_compilers = {
\ 'bundle exec': ''}
" rspec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
2013-08-27 11:55:55 -04:00
" Indentation
let g:indent_guides_guide_size=1
let g:indent_guides_enable_on_vim_startup=1
let g:indent_guides_auto_colors=0
" lightline
2013-10-14 00:19:08 -04:00
let g:lightline = {
2013-08-27 11:55:55 -04:00
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
2013-10-01 14:36:44 -04:00
" Functions
" Toggle relative line numbers and cursorline; useful for long line files
function! LargeFileToggle()
set relativenumber!
set cursorline!
2013-07-24 23:06:54 -04:00
set cursorcolumn!
2013-10-14 00:19:08 -04:00
call SyntaxToggle()
endfunction
2013-08-05 22:07:01 -04:00
2013-10-01 14:36:44 -04:00
" Toggle syntax highlighting
function! SyntaxToggle()
2013-10-14 00:19:08 -04:00
if exists("g:syntax_on")
:syntax off
else
syntax enable
endif
call SetColors()
2013-10-01 14:36:44 -04:00
endfunction
2013-08-05 22:07:01 -04:00
" Rename current file - from github/garybernhardt
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
2013-10-01 14:36:44 -04:00
2014-05-09 01:16:01 -04:00
" Blink current search item - from Damian Conway 'More Instantly Better Vim'
function! HLNext (blinktime)
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('ErrorMsg', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
2013-10-01 14:36:44 -04:00
" Set special case colors
function! SetColors()
highlight CursorLine cterm=NONE ctermbg=234
highlight CursorColumn cterm=NONE ctermbg=234
highlight StatusLine ctermfg=white ctermbg=236
highlight ColorColumn ctermbg=234
highlight IndentGuidesOdd ctermbg=black
highlight IndentGuidesEven ctermbg=234
2014-05-09 00:04:57 -04:00
" fix for vimgutter
highlight clear SignColumn
highlight GitGutterAdd ctermfg=green
highlight GitGutterChange ctermfg=yellow
highlight GitGutterDelete ctermfg=red
highlight GitGutterChangeDelete ctermfg=yellow
2013-10-01 14:36:44 -04:00
endfunction
" Needs to come after SetColors definition
call SetColors()