Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 298 lines (244 sloc) 7.48 KB
" Vim
" ===
" Source ~/.vimrc.before if it exists
if filereadable(expand('~/.vimrc.before'))
source ~/.vimrc.before
endif
set nocompatible " be iMproved
filetype off " required!
call plug#begin('~/.vim/bundle')
Plug 'vim-scripts/L9'
Plug 'chriskempson/base16-vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'plasticboy/vim-markdown'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-surround'
Plug 'vim-scripts/ZoomWin'
Plug 'mattn/webapi-vim'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'airblade/vim-gitgutter'
Plug 'godlygeek/tabular'
Plug 'scrooloose/nerdtree'
Plug 'mattn/gist-vim'
Plug 'epmatsw/ag.vim'
Plug 'tpope/vim-commentary'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'ervandew/supertab'
Plug 'tpope/vim-rbenv'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-repeat'
Plug 'vim-scripts/gem.vim'
Plug 'zerowidth/vim-copy-as-rtf'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'justinmk/vim-gtfo'
Plug 'jayflo/vim-skip'
Plug 'kchmck/vim-coffee-script'
Plug 'gcmt/wildfire.vim'
Plug 'fatih/vim-go'
Plug 'benmills/vim-golang-alternate'
Plug 'junegunn/vim-github-dashboard'
Plug 'cakebaker/scss-syntax.vim'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'ryanss/vim-hackernews'
Plug 'jiangmiao/auto-pairs'
Plug 'sheerun/vim-polyglot'
Plug 'mxw/vim-jsx'
Plug 'fleischie/vim-styled-components'
Plug 'jparise/vim-graphql'
Plug 'sbdchd/neoformat'
Plug 'c-brenn/phoenix.vim'
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'kana/vim-textobj-user'
Plug 'inside/vim-textobj-jsxattr'
Plug 'andyl/vim-textobj-elixir'
Plug 'tek/vim-textobj-ruby'
Plug 'reedes/vim-textobj-sentence'
Plug 'alunny/pegjs-vim'
Plug 'w0rp/ale'
call plug#end()
" Per-directory .vimrc files
set exrc
set secure
" Syntax
" ======
syntax on
syntax enable
set t_Co=256
" General Config
" ==============
let mapleader='\'
set gfn=Menlo:h14
set encoding=utf-8
set number " Line numbers are good
set backspace=indent,eol,start " Allow backspace in insert mode
set history=1000 " Store lots of :cmdline history
set showcmd " Show incomplete cmds down the bottom
set showmode " Show current mode down the bottom
set gcr=a:blinkon0 " Disable cursor blink
set autoread " Reload files changed outside vim
set laststatus=2 " Always show status line
set clipboard=unnamed " Use system clipboard
set hidden " Buffers can exist in the background
set splitright " Opens vertical split right of current window
set splitbelow " Opens horizontal split below current window
"set shortmess=filnxtToOI " see :help shortmess
" http://items.sjbach.com/319/configuring-vim-right
" Mouse
" ======
" Send more characters for redraws
set ttyfast
" Enable mouse use in all modes
set mouse=a
" Set this to the name of your terminal that supports mouse codes.
" Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
set ttymouse=xterm2
" Search Settings
" ===============
set incsearch " Find the next match as we type the search
set hlsearch " Hilight searches by default
set viminfo='100,f1 " Save up to 100 marks, enable capital marks
" Turn Off Swap Files
" ===================
set noswapfile
set nobackup
set nowritebackup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Persistent Undo
" ===============
" Keep undo history across sessions, by storing in file
" Only works in MacVim (gui) mode
if has('gui_running')
set undodir=~/.vim/backups
set undofile
" Hide the toolbar
set guioptions-=T
endif
" Indentation and Display
" =======================
set autoindent
set smartindent
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
filetype plugin on
filetype indent on
set list listchars=tab:\ \ ,trail:· " Display tabs and trailing spaces visually
set nowrap " Don't wrap lines
set linebreak " Wrap lines at convenient points
" Folds
" =====
set foldmethod=indent " Fold based on indent
set foldnestmax=3 " Deepest fold is 3 levels
set nofoldenable " Don't fold by default
" Completion
" ==========
"set wildmode=list:longest
set wildmode=longest,list,full
set wildmenu " Enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ " Stuff to ignore when tab completing
set wildignore+=*vim/backups*
" Scrolling
" =========
" Start scrolling when we're getting close to margins
set scrolloff=10
set sidescrolloff=15
set sidescroll=1
" Status Line
" ===========
set statusline= " Override default
set statusline+=%{fugitive#statusline()[4:-2]} " Show fugitive git info
set statusline+=\ %f\ %m\ %r " Show filename/path
set statusline+=%= " Set right-side status info after this line
set statusline+=%l/%L:%v " Set <line number>/<total lines>:<column>
set statusline+=\ " Set ending space
let base16colorspace=256
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
" NERDTree
" ========
function! ShowFileInNERDTree()
if exists("t:NERDTreeBufName")
NERDTreeFind
else
NERDTree
wincmd l
NERDTreeFind
endif
endfunction
map <leader>f :call ShowFileInNERDTree()<cr>
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
let g:NERDTreeIgnore=['node_modules$[[dir]]']
" Snippets
" ========
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" Git Gutter
" ==========
set signcolumn=yes
let g:gitgutter_eager = 0
" GH Dashboard
" ==========
let g:github_dashboard = { 'username': 'pengwynn', 'password': $GITHUB_TOKEN }
" JSX in .js files
" ==========
let g:jsx_ext_required = 0
" Searching
" ==========
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
endif
" Committing
" =========
"
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that.
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff()
function OpenCommitMessageDiff()
" Save the contents of the z register
let old_z = getreg("z")
let old_z_type = getregtype("z")
try
call cursor(1, 0)
let diff_start = search("^diff --git")
if diff_start == 0
" There's no diff in the commit message; generate our own.
let @z = system("git diff --cached -M -C")
else
" Yank diff from the bottom of the commit message into the z register
:.,$yank z
call cursor(1, 0)
endif
" Paste into a new buffer
vnew
normal! V"zP
finally
" Restore the z register
call setreg("z", old_z, old_z_type)
endtry
" Configure the buffer
set filetype=diff noswapfile nomodified readonly
silent file [Changes\ to\ be\ committed]
" Get back to the commit message
wincmd p
endfunction