dotfiles/vim-files/vimrc

284 lines
6.2 KiB
VimL
Raw Normal View History

2014-03-19 01:53:22 -07:00
set nocompatible " required
filetype off " required
"""" VUNDLE
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install bundles
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
2015-10-08 14:55:54 -07:00
Plugin 'gmarik/vundle'
2015-12-02 18:00:56 -08:00
Plugin 'tpope/vim-sensible'
Plugin 'nanotech/jellybeans.vim'
2015-12-02 16:01:32 -08:00
Plugin 'bling/vim-airline'
2015-12-02 18:00:56 -08:00
Plugin 'bling/vim-bufferline'
Plugin 'myusuf3/numbers.vim'
Plugin 'mhinz/vim-signify'
Plugin 'nathanaelkane/vim-indent-guides'
2015-10-08 14:55:54 -07:00
Plugin 'danro/rename.vim'
Plugin 'pbrisbin/vim-mkdir'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-characterize'
2015-12-02 18:00:56 -08:00
Plugin 'tpope/vim-surround'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-eunuch'
2015-10-08 14:55:54 -07:00
Plugin 'majutsushi/tagbar'
Plugin 'SirVer/ultisnips'
2015-12-02 18:00:56 -08:00
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
2015-10-08 14:55:54 -07:00
Plugin 'kien/ctrlp.vim'
2015-12-02 18:00:56 -08:00
Plugin 'simnalamburt/vim-mundo'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-endwise'
2015-12-02 18:22:25 -08:00
"Plugin 'scrooloose/syntastic'
Plugin 'benekastah/neomake'
2015-10-08 14:55:54 -07:00
Plugin 'Valloric/YouCompleteMe'
2015-12-02 18:00:56 -08:00
Plugin 'kchmck/vim-coffee-script'
Plugin 'mtscout6/vim-cjsx'
filetype plugin indent on " required
""" end vundle
"""" PLUGIN SETTINGS
2014-03-18 18:50:15 -07:00
" YouCompleteMe
nnoremap K :YcmCompleter GoTo<CR>
nnoremap ˚ :YcmCompleter GoToDeclaration<CR>
let g:ycm_goto_buffer_command = 'horizontal-split'
let g:ycm_autoclose_preview_window_after_insertion = 1
2013-08-01 19:40:59 -07:00
2015-12-02 18:00:56 -08:00
" Easymotion
2014-03-18 18:50:15 -07:00
map / <Plug>(easymotion-sn)
2014-03-21 11:47:42 -07:00
omap / <Plug>(easymotion-tn)
2014-03-18 18:50:15 -07:00
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
2015-12-02 18:00:56 -08:00
let g:EasyMotion_landing_highlight = 0
" CtrlP
2015-10-08 14:55:54 -07:00
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
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
endif
2014-03-18 18:50:15 -07:00
2015-12-02 18:00:56 -08:00
" Gundo
2014-03-18 18:50:15 -07:00
map <leader>u :GundoToggle<CR>
2015-12-02 18:00:56 -08:00
" Indent guides
let g:indent_guides_start_level = 2
" Syntastic
let g:syntastic_quiet_messages = {'level': []} " do NOT silence warnings
let g:syntastic_aggregate_errors = 1
2015-12-02 18:22:25 -08:00
"Neomake
autocmd! BufWritePost * Neomake
2014-03-18 18:50:15 -07:00
"""" END PLUGIN SETTINGS
2013-08-02 04:13:40 -07:00
let mapleader=","
set nobackup
set noswapfile
set pastetoggle=<F2>
filetype on
2013-08-01 19:22:01 -07:00
filetype plugin indent on
2013-08-01 19:40:59 -07:00
syntax on
2013-08-01 20:07:12 -07:00
try
2015-12-02 18:00:56 -08:00
colorscheme jellybeans
catch
" deal with it
endtry
2014-03-13 16:40:13 -07:00
2013-08-01 20:07:12 -07:00
set t_Co=256
if &term =~ 'xterm-color'
2014-05-06 12:02:24 -07:00
set t_ut=
2013-08-01 20:07:12 -07:00
endif
2013-08-02 01:46:36 -07:00
set nocompatible
set laststatus=2
2013-08-01 20:07:12 -07:00
if v:version >= 703
2015-12-02 18:00:56 -08:00
"undo settings
2014-05-06 12:02:24 -07:00
set undodir=~/.vim/undofiles
set undofile
2015-12-02 18:00:56 -08:00
let &colorcolumn="80,".join(range(120,999), ",")
endif
2013-08-01 20:07:12 -07:00
set hidden
set showmode
2013-08-01 20:07:12 -07:00
set number
set numberwidth=1
set background=dark
set cursorline
set cursorcolumn
set ruler
2014-03-13 16:40:13 -07:00
" do not redraw while macroing
set lazyredraw
2013-08-01 20:07:12 -07:00
set matchpairs+=<:>
set list
2013-08-02 11:26:14 -07:00
set listchars=tab:>-,trail:-,extends:>,precedes:<,nbsp:+,eol:$
2015-10-08 14:55:54 -07:00
set ts=2
set shiftwidth=2
set expandtab
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
2013-08-01 20:07:12 -07:00
2014-03-13 16:40:13 -07:00
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamed
2013-08-01 20:07:12 -07:00
""" Searching and Patterns
set ignorecase
set smartcase
set smarttab
set hlsearch
2014-03-13 16:40:13 -07:00
" Add the g flag to search/replace by default
set gdefault
2013-08-01 20:07:12 -07:00
""" Folding
set nofoldenable
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"return '[\s]' if trailing white space is detected return '' otherwise
function! StatuslineTrailingSpaceWarning()
2014-05-06 12:02:24 -07:00
if !exists("b:statusline_trailing_space_warning")
if !&modifiable
let b:statusline_trailing_space_warning = ''
return b:statusline_trailing_space_warning
endif
if search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
2013-08-01 20:07:12 -07:00
2013-08-02 01:46:36 -07:00
2013-08-01 20:07:12 -07:00
""" Handy remaps
2014-03-13 16:40:13 -07:00
noremap ; :
inoremap jj <Esc>
map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
2015-12-03 09:06:43 -08:00
"terminal remaps
tnoremap <Esc> <C-\><C-n>
2014-03-13 16:40:13 -07:00
"nnoremap <leader>d :NERDTreeToggle<cr>
map \q :q<CR>
map \w :w<CR>
2014-03-18 18:50:15 -07:00
noremap Q <nop>
2015-10-08 14:55:54 -07:00
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
2013-08-02 04:13:40 -07:00
2014-03-13 16:40:13 -07:00
" Dont reset cursor to start of line when moving around.
set nostartofline
" minimal number of lines to keep above/below cursorline
set scrolloff=10
2013-08-02 04:13:40 -07:00
2013-08-01 20:07:12 -07:00
""" Use the mouse
set mouse=a
2014-03-18 18:50:15 -07:00
""" smart path
set path=.,,**
2014-03-13 16:40:13 -07:00
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded Form: ' .expanded_cmdline)
call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. expanded_cmdline
setlocal nomodifiable
1
endfunction
2014-03-21 11:47:42 -07:00
function! MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function! MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
2015-10-08 14:55:54 -07:00
" Local overrides?
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif