old-dotfiles/.vimrc

552 lines
17 KiB
VimL

if &shell =~# 'fish$'
set shell=bash
endif
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
filetype off
call neobundle#begin(expand('~/.vim/bundle/'))
" Utilities
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'tpope/vim-dispatch'
NeoBundle 'Shougo/vimproc.vim'
NeoBundle 'Shougo/neocomplete'
NeoBundle 'Shougo/neosnippet'
NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'mhinz/vim-startify'
NeoBundle 'junegunn/vim-easy-align'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'sgur/ctrlp-extensions.vim'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'jrhorn424/vim-multiple-cursors'
NeoBundle 'rking/ag.vim'
NeoBundle 'sjl/gundo.vim'
NeoBundle 'tpope/vim-fugitive'
" Enhancements
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-eunuch'
NeoBundle 'dhruvasagar/vim-vinegar'
NeoBundle 'terryma/vim-smooth-scroll'
NeoBundle 'Raimondi/delimitMate'
NeoBundle 'bling/vim-airline'
NeoBundle 'bkad/CamelCaseMotion'
NeoBundle 'vim-scripts/Parameter-Text-Objects'
NeoBundle 'osyo-manga/vim-over'
NeoBundle 'tmhedberg/matchit'
NeoBundle 'matze/vim-move'
NeoBundle 'xolox/vim-misc'
NeoBundle 'xolox/vim-colorscheme-switcher'
NeoBundle 'haya14busa/incsearch.vim'
NeoBundle 'rhysd/clever-f.vim'
NeoBundle 'christoomey/vim-tmux-navigator'
" Language
NeoBundle 'Rip-Rip/clang_complete'
NeoBundle 'dag/vim-fish'
NeoBundle 'marijnh/tern_for_vim'
NeoBundle 'jelera/vim-javascript-syntax'
NeoBundle 'hail2u/vim-css3-syntax'
NeoBundle 'groenewege/vim-less'
NeoBundle 'othree/javascript-libraries-syntax.vim'
NeoBundle 'OmniSharp/omnisharp-vim'
NeoBundle 'xolox/vim-lua-ftplugin'
NeoBundle 'tclem/vim-arduino'
" NeoBundle 'jplaut/vim-arduino-ino/'
" Web
NeoBundle 'mattn/emmet-vim'
NeoBundle 'ap/vim-css-color'
NeoBundle 'KabbAmine/vCoolor.vim'
NeoBundle 'Valloric/MatchTagAlways'
NeoBundle 'vim-scripts/closetag.vim'
NeoBundle 'jaxbot/browserlink.vim'
call neobundle#end()
filetype plugin indent on
set history=2000
set ruler
set laststatus=2
set formatoptions=t
set relativenumber
set noshowmatch
set splitbelow
set splitright
set hidden
set wildmenu
set wildmode=longest,full
set backspace=eol,start,indent
set novisualbell
set noerrorbells
let loaded_matchparen=0
set clipboard=unnamed
set tabstop=4
set shiftwidth=4
set expandtab
set sessionoptions-=
set sessionoptions-=buffers
set sessionoptions-=blank
set guioptions-=r
set guioptions-=L
set guioptions-=e
set mouse=a
set foldmethod=syntax
set foldcolumn=1
set nrformats+=alpha
set nowrap
let mapleader = "\<Space>"
" Macros
" To List
noremap <Leader>mtl f[xxbi<<Esc>ea><Esc>bbiList<Esc>b
" To Array
noremap <Leader>mta f>Bdiwxf>xi[]<Esc>B
" Replace Word
nnoremap <Leader>rw :%s/\<<C-r><C-w>\>/
" Clean up Interface
nnoremap <Leader>mi ddJO<Esc>4jdd2kcc
" Extract Definition
nnoremap <Leader>med "vyiwmv^/\u<CR>:nohlsearch<CR>y`v"ty`vo<C-r>v = new <C-r>t<C-h>();<Esc>^v$hdV"ldk`v
" Delete Outer Function
nnoremap <Leader>mdaf viBdVkpmtgv<}dd`t
" Delete Surrounding Function
vnoremap <Leader>mdif "tdxXvBd<C-r>t
" Add Constructor
nnoremap <Leader>mac "tyiwjopublic <C-r>t() {}<Esc>i<CR><Esc>O//<Esc>
" Create Yield from IEnumerator
nnoremap <Leader>mye "tyiwmtowhile (<C-r>t.MoveNext()) yield return <C-r>t.Current;<Esc>`t
" Create Yield from Task
nnoremap <Leader>myt "tyiwmtowhile (!<C-r>t.IsCompleted) yield return null;<Esc>`t
" Add Curly Braces to inline if
nnoremap <Leader>mif ^f(%ls {<Esc>li<CR><Esc>o}<Esc>kw
" Surround with if statement
vnoremap <Leader>mif dOif () {}<Esc>i<CR><CR><Esc>kVp=iBk^f(a
" Add ContextMenu to Function
nnoremap <Leader>mcm ^f(hyiwO[ContextMenu("<C-R>"")]<Esc>j^f(b
" Add this.varName = varName;
nnoremap <Leader>mthis mmyiwothis.<C-r>* = <C-r>*;<Esc>`m
" Extra Line
" alt + o
noremap <Space> <nop>
noremap <Leader>/ :nohlsearch<CR>
nnoremap D d$
nnoremap Y y$
nnoremap vv ^v$h
noremap \ q
nnoremap <Leader>vim :tabe $MYVIMRC<CR>
noremap <Leader>sr :w<CR>:so %<CR>
nnoremap ' `
nnoremap ` '
noremap $ g_
nnoremap <C-s> :w<CR>
noremap <Leader>= mt=i}`t
" Buffers
nnoremap <Leader>q :bw<CR>
nnoremap <Leader>bb :b#<CR>
nnoremap <Leader>bd :b#<CR>:bd#<CR>
" Windows
nnoremap <Leader>wq :windo bw<CR>
noremap <Right> <C-w>10<
noremap <Left> <C-w>10>
noremap <Up> <C-w>4+
noremap <Down> <C-w>4-
" MacVim has different alt codes so gotta check if gui_running, there are the codes in order
" alt + ;
" alt + o & alt + O
" alt + h & alt + l
" if has("gui_running")
" inoremap » <Esc>A;
" nnoremap » A;<Esc>
" nnoremap ï o<Esc>k
" nnoremap Ï O<Esc>j
" noremap è gT
" noremap ì gt
" noremap <silent> È :tabmove -1<CR>
" nnoremap <silent> Ì :tabmove +1<CR>
" else
inoremap<Esc>A;
nnoremapA;<Esc>;
nnoremap ø o<Esc>k
nnoremap Ø O<Esc>j
noremap ˙ gT
noremap ¬ gt
noremap <silent> Ó :tabmove -1<CR>
nnoremap <silent> Ò :tabmove +1<CR>
" Map vim-move in terminal
vmap<Plug>MoveBlockDown
vmap ˚ <Plug>MoveBlockUp
nmap<Plug>MoveLineDown
nmap ˚ <Plug>MoveLineUp
" endif
" open Help in vertical window
if (!exists(":H"))
command -nargs=* -complete=help H vertical belowright help <args>
endif
augroup insert_mode_stuff
autocmd!
au InsertEnter * set cursorline
au InsertLeave * set nocursorline
autocmd BufNewFile,BufRead * setlocal formatoptions=t
autocmd BufNewFile,BufRead * set colorcolumn=80
augroup END
command! CDC cd %:p:h
" Show syntax definition where cursor is placed
func! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
nnoremap <Leader>syn :call SynStack()<CR>
" Toggle booleans
func! ToggleBool()
let l:word = expand("<cword>")
if l:word ==? "true"
let l:word = "false"
elseif l:word ==? "false"
let l:word = "true"
elseif l:word ==? "public"
let l:word = "protected"
elseif l:word ==? "protected"
let l:word = "private"
elseif l:word ==? "private"
let l:word = "public"
else
return "\<c-x>"
endif
return "ciw" . l:word . "\<Esc>"
endfunc
nnoremap <expr> <c-x> ToggleBool()
command! Retab set ts=2 noet | retab! | set et ts=4 | retab
command! DeleteBadWhiteSpace %s/\s\+$//e | %s/^\s\+$//e | %s/\r//e
command! Reformat %s/\(\<if\|for\|foreach\|while\|do\>\)(/\1 (/e | g/) {\$/normal $i<CR><Esc>/e
" Searching
set incsearch
set ignorecase
set smartcase
set hlsearch
nohlsearch
" Appearance
syntax on
set number
set t_Co=256
set linespace=2
if has("gui_running")
set guifont=Andale\ Mono:h12
colorscheme jellybeans
" colorscheme autumnleaf
else
" colorscheme solarized
colorscheme jellybeans
" Solarized
" set background=dark
endif
func! SetFont(size)
exec 'set guifont=Andale\ Mono:h' . a:size
endfun
command! -nargs=1 FontSize :call SetFont(<f-args>)
" DelimitMate
let g:delimitMate_expand_cr=1
let g:delitMate_expand_space=0
" CameCase Text Object
map <silent> q <Plug>CamelCaseMotion_w
map <silent> Q <Plug>CamelCaseMotion_b
omap <silent> iq <Plug>CamelCaseMotion_iw
xmap <silent> iq <Plug>CamelCaseMotion_iw
" Parameter Text Object
let g:no_parameter_object_maps = 1
vmap <silent> ia <Plug>ParameterObjectI
omap <silent> ia <Plug>ParameterObjectI
vmap <silent> aa <Plug>ParameterObjectA
omap <silent> aa <Plug>ParameterObjectA
" Easy Motion
let g:EasyMotion_do_mapping=0
let g:EasyMotion_keys = 'asdfjkleirwuo'
nmap , <Plug>(easymotion-prefix)
nmap S <Plug>(easymotion-sl2)
nmap ,f <Plug>(easymotion-f)
nmap ,F <Plug>(easymotion-F)
nmap ,t <Plug>(easymotion-t)
nmap ,T <Plug>(easymotion-T)
nmap ,w <Plug>(easymotion-w)
nmap ,W <Plug>(easymotion-W)
nmap ,b <Plug>(easymotion-b)
nmap ,B <Plug>(easymotion-B)
nmap ,e <Plug>(easymotion-e)
nmap ,E <Plug>(easymotion-E)
nmap ,ge <Plug>(easymotion-ge)
nmap ,gE <Plug>(easymotion-gE)
nmap ,j <Plug>(easymotion-j)
nmap ,k <Plug>(easymotion-k)
vmap ,j <Plug>(easymotion-j)
vmap ,k <Plug>(easymotion-k)
nmap ,n <Plug>(easymotion-n)
nmap ,N <Plug>(easymotion-N)
nmap ,s <Plug>(easymotion-s2)
nmap ,/ <Plug>(easymotion-sn)
" Clever-F
let g:clever_f_across_no_line=1
" Incsearch.vim
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
let g:incsearch#consistent_n_direction = 1
let g:incsearch#emacs_like_keymap = 1
" Javascript Libraries
let g:used_javascript_libs = 'jquery,angularjs,angularui,sugar'
" Gundo
noremap <Leader>g :GundoToggle<CR>
" Easy Align
vmap <Enter> <Plug>(EasyAlign)
nmap <Leader>e <Plug>(EasyAlign)
" Go to URLs
vnoremap <leader>du "uy:silent !open http://docs.unity3d.com/Documentation/ScriptReference/<C-r>u.html<CR>
nnoremap <leader>dg :call GoToUrl("google")<CR>
nnoremap <leader>du :call GoToUrl("unity")<CR>
nnoremap <leader>dm :call GoToUrl("msdn")<CR>
fun! GoToUrl(options)
let keyword = expand("<cword>")
if (a:options == "google")
let url = "http://www.google.com/search?q="
elseif (a:options == "unity")
let url = "http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q="
elseif (a:options == "msdn")
let url = "http://social.msdn.microsoft.com/Search/en-US?query="
endif
exec '!open ' . url . keyword
endfun
" Scrolling Speed
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 10, 3)<CR>
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 10, 3)<CR>
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 10, 4)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 10, 4)<CR>
noremap <silent> <c-y> :call smooth_scroll#up(&scroll/5, 15, 1)<CR>
noremap <silent> <c-e> :call smooth_scroll#down(&scroll/5, 15, 1)<CR>
" Startify
let g:startify_session_dir = "~/.vim/sessions/"
let g:startify_list_order = [ ['SESSIONS'], 'sessions', ['FILES'], 'files', ['BOOKMARKS'], 'bookmarks', ]
let g:startify_bookmarks = ["~/.vim/", "ftp://ftp.ferano.io//", "~/Documents/Work/", "~/Documents/Work/jflib/Assets/jflib/", "~/Documents/Work/jamtok/project/Assets/", "~/Documents/Work/poptok/Assets/Scripts"]
let g:startify_files_number = 7
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
" Load custom header
:source ~/.vim/startify_header.vim
" NERDTree
let NERDTreeIgnore=['.meta$[[file]]']
" Emmet
let g:user_emmet_leader_key='<C-Z>'
let g:user_emmet_install_global = 0
augroup emmet_stuff
autocmd FileType html,css EmmetInstall
augroup END
" MatchTagAlways
highlight MatchParen ctermfg=black ctermbg=lightgreen guifg=#002b36 guibg=#b58900
" Ag.vim
let g:agformat="%f:%l:%m"
noremap <Leader>a :Ag!<space>
let g:agprg="ag --column --smart-case"
" C Stuff
" augroup c_bindings
" autocmd!
" au FileType c noremap <silent><buffer> ) ?{<CR>w99[{:nohlsearch<CR>
" au FileType c noremap <silent><buffer> ( j0?{<CR>w99[{%/{<CR>:nohlsearch<CR>
" augroup END
" Arduino
augroup arduino_files
autocmd!
au BufRead,BufNewFile *.pde set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
augroup END
" let g:vim_arduino_library_path = "/Applications/Arduino.app"
" let g:vim_arduino_serial_port = "/dev/tty.usbmodem1d1131"
" Lua Stuff
let g:lua_check_syntax = 0
let g:lua_complete_omni = 1
" Compile and run current C file
nnoremap <Leader>cc :!gcc -Wall -o %:r %<CR>
nnoremap <Leader>cr :!gcc -Wall -o %:r % && ./%:r<CR>
let g:clang_library_path="/Users/josephferano/src/clang+llvm-3.3-x86_64-apple-darwin12/lib/libclang.dylib"
" CtrlP
set wildignore+=*/tmp/*,*/Temp/*,*/Library/*,*/Builds/*,*.png,*.jpg,*.asset,*.unity,*.csproj,*.gif,*.so,*.swp,*.zip,*.meta,*.ttc,*.userprefs,*.mat,*.mp3,*.ogg,*.wav,*.bmp,*.anim,*.TTF,tags
let g:ctrlp_custom_ignore = { 'dir': '\v[\/](obj|bin|node_modules|bower_components)|(\.(swp|ico|git|svn))$', 'file': '\v\.(exe|so|dll|meta|prefab|unity3d|sln)$', 'link': 'some_bad_symbolic_links', }
let g:ctrlp_map = '<c-p>p'
noremap <C-p><C-p> :CtrlP<CR>
noremap <C-p>m :CtrlPMRU<CR>
noremap <C-p>b :CtrlPBuffer<CR>
noremap <C-p>t :CtrlPBufTag<CR>
noremap <C-p>l :CtrlPLine<CR>
noremap <C-p>y :CtrlPYankring<CR>
noremap <C-p>c :CtrlPCmdline <CR>
let g:ctrlp_match_window="ttb,min:1,max:15,results:15"
let g:ctrlp_session_dir=".vim/sessions/"
let g:ctrlp_by_filename = 1
let g:ctrlp_working_path_mode = ''
let g:ctrlp_buffer_func = { 'enter': 'CtrlpMaps' }
func! CtrlpMaps()
nnoremap <buffer> <silent> <c-@> :call <sid>DeleteBuffer()<cr>
" nnoremap <buffer> <silent> <c-q> :call <sid>QuickLook()<cr>
endfunc
func! s:QuickLook()
let line = getline('.')
let l:path = getcwd() . substitute(line, '> ', '/', "")
call system("qlmanage -p 2>/dev/null '" . path . "'")
endfunc
func! s:DeleteBuffer()
let line = getline('.')
let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+'))
\ : fnamemodify(line[2:], ':p')
exec "bd" bufid
exec "norm \<F5>"
endfunc
" Syntastic
let g:syntastic_cs_checkers = ['syntax']
" OmniSharp
augroup omnisharp_complete
autocmd!
autocmd FileType cs set commentstring=//\ %s
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
autocmd FileType cs nnoremap <buffer> <Leader>og :OmniSharpGotoDefinition<cr>
autocmd FileType cs nnoremap <buffer> <Leader>ofi :OmniSharpFindImplementations<cr>
autocmd FileType cs nnoremap <buffer> <Leader>ofu :OmniSharpFindUsages<cr>
autocmd FileType cs nnoremap <buffer> <Leader>odc :OmniSharpDocumentation<cr>
autocmd FileType cs nnoremap <buffer> <Leader>oft :OmniSharpFindType<cr>
autocmd FileType cs nnoremap <buffer> <Leader>ofs :OmniSharpFindSymbol<cr>
autocmd FileType cs nnoremap <buffer> <Leader>ofm :OmniSharpFindMembers<cr>
autocmd FileType cs nnoremap <buffer> <Leader>oht :OmniSharpHighlightTypes<cr>
autocmd FileType cs nnoremap <buffer> <Leader>orl :OmniSharpReloadSolution<cr>
autocmd FileType cs nnoremap <buffer> <Leader>oso :OmniSharpStopServer<cr>
autocmd FileType cs nnoremap <buffer> <Leader>osa :OmniSharpStartServer<cr>
autocmd FileType cs nnoremap <buffer> <Leader>oad :OmniSharpAddToProject<cr>
autocmd FileType cs nnoremap <buffer> <Leader>ob :OmniSharpBuildAsync<cr>
autocmd FileType cs nnoremap <buffer> <Leader>orn :OmniSharpRenameTo<space><C-r><C-w><C-f>h
autocmd FileType cs nnoremap <buffer> <Leader>oca :OmniSharpGetCodeActions<cr>
autocmd FileType cs vnoremap <buffer> <Leader>oca :call OmniSharp#GetCodeActions('visual')<cr>
autocmd FileType cs nnoremap <buffer> <Leader>f :OmniSharpTypeLookup<cr>
autocmd FileType cs nnoremap <buffer> <Leader>F mmF(h:OmniSharpTypeLookup<cr>`m
autocmd FileType cs nnoremap <silent> <buffer> ( :OmniSharpNavigateDown<cr>
autocmd FileType cs nnoremap <silent> <buffer> ) :OmniSharpNavigateUp<cr>
augroup END
set completeopt=longest,menuone
let g:OmniSharp_typeLookupInPreview = 0
let g:OmniSharp_timeout = 100
if has("gui_running")
hi link csAttributeType Constant
hi link csUnspecifiedStatement Constant
hi link csInterfaceDeclaration Repeat
else
hi link csAttributeType Special
hi link csUnspecifiedStatement PreProc
hi link csInterfaceDeclaration StorageClass
hi link csModifier Identifier
hi link csClass Constant
hi link csType Constant
hi link CSharpUserType Identifier
endif
" source ~/Documents/Work/vim-csharp-repl/plugin/csharp-repl.vim
" NeoComplete
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 2
let g:neocomplete#max_list = 25
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
call neocomplete#custom#source('_', 'sorters', [])
if !exists('g:neocomplete#sources')
let g:neocomplete#sources = {}
endif
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#disable_auto_complete = 0
inoremap <expr><C-l> neocomplete#complete_common_string()
inoremap <expr><C-h> pumvisible() ? neocomplete#cancel_popup() : "\<C-h>"
imap <expr><Tab> pumvisible() ? neocomplete#close_popup() : "\<Tab>"
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#force_overwrite_completefunc = 1
let g:neocomplete#sources.cs = ['omni']
let g:neocomplete#sources#omni#input_patterns.cs = '.*[^-!@%?/|&\{}\+\*\(<>\")\=);]'
let g:neocomplete#sources#omni#input_patterns.js = '[^. \t]\.\w*'
let g:neocomplete#sources#omni#input_patterns.c = '[^[:digit:] *;\{\()]\w*'
let g:neocomplete#sources#omni#input_patterns.lua = '[^. \t]\.\w*'
let g:clang_complete_auto=1
let g:clang_auto_select=0
let g:clang_use_library=1
let g:neocomplete#enable_refresh_always = 0
augroup js_aus
autocmd!
autocmd FileType javascript setlocal omnifunc=tern#Complete
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
augroup END
" NeoSnippet
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <C-s> <Plug>(neosnippet_expand_or_jump)
xmap <C-s> <Plug>(neosnippet_expand_target)
let g:neosnippet#enable_snipmate_compatibility = 1
let g:neosnippet#snippets_directory='~/.vim/snippet'
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
if has('conceal')
set conceallevel=2 concealcursor=i
endif
"