" =================================================== " INITIALIZE " =================================================== if has('vim_starting') set nocompatible set runtimepath+=$HOME/.vim/bundle/neobundle.vim/ endif call neobundle#begin(expand('$HOME/.vim/bundle')) NeoBundleFetch 'Shougo/neobundle.vim' " File management, search, navigation NeoBundle 'mileszs/ack.vim' NeoBundle 'kien/ctrlp.vim' NeoBundle 'sjl/gundo.vim' NeoBundle 'scrooloose/nerdtree' NeoBundle 'vim-scripts/restore_view.vim' NeoBundle 'jeetsukumaran/vim-buffergator' NeoBundle 'vim-scripts/YankRing.vim' NeoBundle 'vim-scripts/zoomwintab.vim' " Vim UI/UX NeoBundle 'bling/vim-airline' NeoBundle 'reedes/vim-colors-pencil' NeoBundle 'gcmt/taboo.vim' " Syntax highlighting NeoBundle 'jtratner/vim-flavored-markdown.git' NeoBundle 'elzr/vim-json' NeoBundle 'kchmck/vim-coffee-script' NeoBundle 'pangloss/vim-javascript' " Snippets & autocomplete NeoBundle 'sirver/ultisnips' NeoBundle 'Valloric/YouCompleteMe' NeoBundle 'honza/vim-snippets' " Formatters, selectors, accelerators NeoBundle 'mattn/emmet-vim' NeoBundle 'vim-scripts/matchit.zip' NeoBundle 'godlygeek/tabular' NeoBundle 'tpope/vim-commentary' NeoBundle 'tpope/vim-endwise' NeoBundle 'terryma/vim-multiple-cursors' NeoBundle 'tpope/vim-repeat' NeoBundle 'tpope/vim-surround' " Ruby/Rails NeoBundle 'vim-ruby/vim-ruby' NeoBundle 'tpope/vim-rails' NeoBundle 'henrik/vim-ruby-runner' NeoBundle 'nelstrom/vim-textobj-rubyblock' NeoBundle 'skalnik/vim-vroom' " Git NeoBundle 'tpope/vim-fugitive' NeoBundle 'mhinz/vim-signify' " Dependencies & utilities NeoBundle 'MarcWeber/vim-addon-mw-utils' NeoBundle 'kana/vim-textobj-user' NeoBundle 'tomtom/tlib_vim' call neobundle#end() filetype plugin indent on NeoBundleCheck " =================================================== " VISUALS " =================================================== syntax enable " Colorscheme set t_Co=256 set background=dark colorscheme pencil " Fix for pencil comments hi Comment cterm=NONE ctermbg=00 ctermfg=08 " hi ColorColumn ctermbg=27 " Tab styles hi TabLineFill ctermfg=08 ctermbg=08 hi TabLine ctermfg=13 ctermbg=08 hi TabLineSel ctermfg=02 ctermbg=00 " Interactive cursor let &t_SI = "\]50;CursorShape=1\x7" let &t_EI = "\]50;CursorShape=0\x7" " For MacVim if has("gui_running") colorscheme pencil set guifont=Monaco:h13 set guioptions-=r set guioptions-=T set guioptions-=L set fuoptions=maxvert,maxhorz set columns=1000 au GUIEnter * set fullscreen endif " =================================================== " REMAPS " =================================================== let mapleader="," " Movement nnoremap j gj nnoremap k gk nnoremap } nnoremap { nnoremap } nnoremap { nnoremap ^ nnoremap $ vnoremap ^ vnoremap $ " Windows nnoremap wl l nnoremap wh h nnoremap wj j nnoremap wk k nnoremap w= = nnoremap wL L nnoremap wH H nnoremap wJ J nnoremap wK K nnoremap wf x nnoremap wo :ZoomWinTabToggle " Tabs nnoremap t :tabnew nnoremap T T nnoremap { gT nnoremap } gt " File navigation, search, replace nnoremap n :NERDTreeToggle nnoremap f :NERDTreeFind nnoremap s :Ack nnoremap :noh nnoremap * *:%s// " Keep search matches in the middle of the window nnoremap n nzzzv nnoremap N Nzzzv " Keep indent selected vnoremap >gv vnoremap >gv vnoremap < imap " Convential select all nnoremap a ggVG " Change pwd to current file nnoremap cd :lcd%:p:h:pwd " Open in pwd cnoremap e e =expand('%:p:h') . '/' " Copy & paste to clipboard vnoremap y "*y nnoremap p "*p " Drag block up/down vnoremap :m'>+gv vnoremap :m-2gv " Toggle line wrapping nnoremap w :set wrap! nnoremap i :set list! " Toggle relative numbers in visual line mode nnoremap v v:set nonu rnugv nnoremap V V0:set nonu rnugv nnoremap :set nonu rnugv vnoremap :set nornu nu autocmd CursorMoved * if mode() !~# "[vV\]" | set nornu nu | endif " Use sane regexes nnoremap / /\v vnoremap / /\v " Tags nnoremap mzzvzz15`z:Pulse nnoremap vLmzzMzvzz15`z:Pulse nnoremap \ :tab split:exec("tag ".expand(""))`z:Pulse nnoremap tt :!ctags -R . " Sudo to write cnoremap w!! w !sudo tee % >/dev/null " Modify command line cursor movement cnoremap cnoremap " Gundo nnoremap G :GundoToggle " Tabularize vnoremap T :Tabularize / " YankRing nnoremap Y :YRShow " =================================================== " Settings " =================================================== " Searching set incsearch set ignorecase set smartcase set showmatch set hlsearch set gdefault set wildmenu set wildmode=list:longest,full set wildignore+=*/.tmp/*,*.so,*.swp,*.zip,*.git set shellpipe=> " Tabbing and indents set autoindent set smartindent set expandtab set shiftwidth=2 set scrolloff=3 set softtabstop=2 set tabstop=8 set shiftround " Formatting, layout, misc tweeks set fileencoding=utf-8 set encoding=utf-8 set backspace=indent,eol,start set autoread set autowrite set number set ruler set cursorline set cursorcolumn " set colorcolumn=80 set visualbell set showcmd set laststatus=2 set showmode! set wrap set linebreak let &showbreak = '↪ ' set listchars=tab:▸\ ,trail:·,eol:¬ " set splitright " Makes things faster? set notimeout set ttimeout set ttimeoutlen=10 set lazyredraw " Better completion set complete=.,w,b,u,t set completeopt=longest,menuone,preview " Backups, swapfiles, views set backup set noswapfile set history=1000 set undofile set undoreload=10000 set viewoptions=cursor,folds set undodir=~/.vim/tmp/undo// set backupdir=~/.vim/backup// set directory=~/.vim/tmp/swap// set viewdir=~/.vim/tmp/view// set viminfo+=n$HOME/.vim/tmp/.viminfo set tags=./tmp/tags,./tags,tags " Make those folders automatically if they don't already exist. if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&backupdir)) call mkdir(expand(&backupdir), "p") endif if !isdirectory(expand(&directory)) call mkdir(expand(&directory), "p") endif if !isdirectory(expand(&viewdir)) call mkdir(expand(&viewdir), "p") endif " Don't try to highlight lines longer than 800 characters. set synmaxcol=800 " =================================================== " PLUGINS " =================================================== " NERDTree let NERDTreeShowHidden=1 let NERDTreeQuitOnOpen=1 let NERDTreeBookmarksFile=expand("$HOME/.vim/tmp/NERDTreeBookmarks") " Ctrlp let g:ctrlp_match_window='order:ttb,max:30' let g:ctrlp_clear_cache_on_exit=1 let g:ctrlp_cache_dir='$HOME/.vim/tmp/cache/ctrlp' let g:ctrlp_arg_map=1 let g:ctrlp_max_files=0 let g:ctrlp_max_depth=40 let g:ctrlp_custom_ignore = '\v[\/](\.git|\.hg|\.svn)$' " Ack let g:ackhighlight=1 " Airline let g:airline_left_sep='' let g:airline_right_sep='' let g:airline#extensions#whitespace#enabled=0 let g:airline_theme='pencil' " Buffergator let g:buffergator_viewport_split_policy='R' let g:buffergator_split_size=50 " Taboo let g:taboo_tab_format=' %f ' " YankRing let g:yankring_history_dir='$HOME/.vim/tmp' let g:yankring_clipboard_monitor=0 " YR - Stop polluting my global map space let g:yankring_n_keys='' let g:yankring_o_keys='' let g:yankring_zap_keys='' let g:yankring_ignore_operator='' let g:yankring_v_key='' let g:yankring_del_v_key='' let g:yankring_paste_n_bkey='' let g:yankring_paste_n_akey='' let g:yankring_paste_v_key='' let g:yankring_replace_n_pkey='' let g:yankring_replace_n_nkey='' " UltiSnips let g:UltiSnipsExpandTrigger='' let g:UltiSnipsEditSplit='vertical' " Emmet " Usage: e, let g:user_emmet_leader_key='' let g:user_emmet_prevkey='p' " RubyRunner let g:RubyRunner_key = 'e' let g:RubyRunner_keep_focus_key = 'E' let g:RubyRunner_open_below = 1 let g:RubyRunner_window_size = 10 " Vim-Javascript " let g:javascript_enable_domhtmlcss = 1 " let g:used_javascript_libs = 'jquery,angularjs,angularui,jasmin,coffeescript' " let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"] let g:html_indent_inctags = "html,body,head,tbody" " Vroom let g:vroom_clear_screen = 0 let g:vroom_use_binstubs = 1 let g:vroom_use_bundle_exec = 0 " =================================================== " CUSTOM FUNCTIONS " =================================================== " Git autocmd Filetype gitcommit setlocal spell textwidth=72 autocmd Filetype gitcommit setlocal colorcolumn=80 " Use The Silver Searcher https://github.com/ggreer/the_silver_searcher if executable('ag') let g:ackprg='ag --nogroup --column' " 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 --hidden -l --nocolor -g ""' endif " Hide cursor crosshairs when not in focus augroup cline au! au WinLeave,InsertEnter * set nocursorline au WinLeave,InsertEnter * set nocursorcolumn au WinEnter,InsertLeave * set cursorline au WinEnter,InsertLeave * set cursorcolumn augroup END " Sets Quickfix window height au FileType qf call AdjustWindowHeight(3, 30) function! AdjustWindowHeight(minheight, maxheight) exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _" endfunction " Clear register function! ClearRegisters() let regs='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-="*+' let i=0 while (iClearRegisters() " Clear undo history function! ForgetUndo() let old_undolevels = &undolevels set undolevels=-1 exe "normal a \\" let &undolevels = old_undolevels unlet old_undolevels endfunction command! -nargs=0 ClearUndo call ForgetUndo() " Make JavaScript brackets close properly augroup ft_javascript au! au Filetype javascript inoremap { {}.kA augroup END " Pulse Line - used to highlight matches when navigating ctags function! s:Pulse() let current_window = winnr() windo set nocursorline execute current_window . 'wincmd w' setlocal cursorline redir => old_hi silent execute 'hi CursorLine' redir END let old_hi = split(old_hi, '\n')[0] let old_hi = substitute(old_hi, 'xxx', '', '') let steps = 9 let width = 1 let start = width let end = steps * width let color = 233 for i in range(start, end, width) execute "hi CursorLine ctermbg=" . (color + i) redraw sleep 6m endfor for i in range(end, start, -1 * width) execute "hi CursorLine ctermbg=" . (color + i) redraw sleep 6m endfor execute 'hi ' . old_hi endfunction command! -nargs=0 Pulse call s:Pulse()