Last active
May 26, 2016 16:07
-
-
Save pruan-rht/621ab6b3cff137c3000e to your computer and use it in GitHub Desktop.
Peter's .vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
set guioptions+=T | |
filetype off | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'Vundlevim/Vundle.vim' | |
" Golang all-in-one plugin | |
Plugin 'fatih/vim-go' | |
" Auto-completion | |
Plugin 'Valloric/YouCompleteMe' | |
" Tagbar on the side for quick navigation of source code | |
Plugin 'majutsushi/tagbar' | |
" Shiny status bar for vim | |
Plugin 'bling/vim-airline' | |
" Fuzzy finder | |
Plugin 'ctrlpvim/ctrlp.vim' | |
" git plugin | |
Plugin 'tpope/vim-fugitive' | |
" Better defaults | |
Plugin 'tpope/vim-sensible' | |
" track white spaces | |
Plugin 'ntpeters/vim-better-whitespace' | |
" syntax checking (lint) | |
Plugin 'scrooloose/syntastic' | |
""""""""" | |
Plugin 'vim-ruby/vim-ruby' | |
Plugin 'tpope/vim-rails' | |
Plugin 'tpope/vim-surround' | |
Plugin 'godlygeek/tabular' | |
Plugin 'bogado/file-line' | |
Plugin 'scrooloose/nerdtree' | |
Plugin 'Xuyuanp/nerdtree-git-plugin' | |
""" different language and indent support | |
call vundle#end() | |
filetype plugin indent on | |
autocmd BufWritePre * StripWhitespace | |
set smartindent | |
set autoindent | |
let base16colorspace=256 " Access colors present in 256 colorspace | |
" colorscheme base16-ocean | |
colorscheme peter | |
set guifont=Hack:h12 | |
set incsearch | |
""" syntatic | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 1 | |
let g:syntastic_quiet_messages = { "type": "style" } | |
"syntastic settings | |
let syntastic_stl_format = '[Syntax: %E{line:%fe }%W{#W:%w}%B{ }%E{#E:%e}]' | |
" ignore feature files | |
let g:syntastic_mode_map = { | |
\ "mode": "active", | |
\ "passive_filetypes": ["cucumber"] } | |
"let g:syntastic_ruby_checkers = ['ruby-lint'] | |
"let g:syntastic_ruby_rubocop_exec = '/Users/pruan/.rvm/rubies/ruby-2.3.0/bin/ruby /Users/pruan/.rvm/gems/ruby-2.3.0/bin/rubocop' | |
"=========== nerdtree git plugin ============== | |
let g:NERDTreeIndicatorMapCustom = { | |
\ "Modified" : "✹", | |
\ "Staged" : "✚", | |
\ "Untracked" : "✭", | |
\ "Renamed" : "➜", | |
\ "Unmerged" : "═", | |
\ "Deleted" : "✖", | |
\ "Dirty" : "✗", | |
\ "Clean" : "✔︎", | |
\ "Unknown" : "?" | |
\ } | |
" ================ General Config ==================== | |
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 visualbell "No sounds | |
set autoread "Reload files changed outside vim | |
" This makes vim act like all other editors, buffers can | |
" exist in the background without being in a window. | |
" http://items.sjbach.com/319/configuring-vim-right | |
set hidden | |
" ================ Turn Off Swap Files ============== | |
set noswapfile | |
set nobackup | |
set nowb | |
" ================ Indentation ====================== | |
set autoindent | |
set smartindent | |
set smarttab | |
set expandtab | |
filetype plugin on | |
filetype indent on | |
" Display tabs and trailing spaces visually | |
set list listchars=tab:\ \ ,trail:· | |
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 "dont fold by default | |
" ================ Completion ======================= | |
set wildmode=list:longest | |
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* | |
set wildignore+=*sass-cache* | |
set wildignore+=*DS_Store* | |
set wildignore+=vendor/rails/** | |
set wildignore+=vendor/cache/** | |
set wildignore+=*.gem | |
set wildignore+=log/** | |
set wildignore+=tmp/** | |
set wildignore+=*.png,*.jpg,*.gif | |
" | |
" ================ Scrolling ======================== | |
set scrolloff=8 "Start scrolling when we're 8 lines away from margins | |
set sidescrolloff=15 | |
set sidescroll=1 | |
" ================ Search =========================== | |
set incsearch " Find the next match as we type the search | |
set hlsearch " Highlight searches by default | |
set ignorecase " Ignore case when searching... | |
set smartcase " ...unless we type a capital | |
" Turn off vi compatibility | |
set nocompatible | |
set smartindent | |
set autoindent | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
"if has("vms") | |
" set nobackup " do not keep a backup file, use versions instead | |
"else | |
" set backup " keep a backup file | |
"endif | |
set history=50 " keep 50 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
if exists('+colorcolumn') | |
set colorcolumn=80 | |
else | |
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
if $HOME !~# '^/Users/' | |
filetype off " Debian preloads this before the runtimepath is set | |
endif | |
filetype plugin indent on | |
filetype on | |
augroup FTMisc " {{{2 | |
autocmd! | |
autocmd FocusLost * silent! wall | |
autocmd FocusGained * if !has('win32') | silent! call fugitive#reload_status() | endif | |
autocmd SourcePre */macros/less.vim set laststatus=0 cmdheight=1 | |
if v:version >= 700 && isdirectory(expand("~/.trash")) | |
autocmd BufWritePre,BufWritePost * if exists("s:backupdir") | set backupext=~ | let &backupdir = s:backupdir | unlet s:backupdir | endif | |
autocmd BufWritePre ~/* | |
\ let s:path = expand("~/.trash").strpart(expand("<afile>:p:~:h"),1) | | |
\ if !isdirectory(s:path) | call mkdir(s:path,"p") | endif | | |
\ let s:backupdir = &backupdir | | |
\ let &backupdir = escape(s:path,'\,').','.&backupdir | | |
\ let &backupext = strftime(".%Y%m%d%H%M%S~",getftime(expand("<afile>:p"))) | |
endif | |
autocmd User Rails-javascript setlocal ts=2 | |
autocmd User Fugitive if filereadable(fugitive#buffer().repo().dir('fugitive.vim')) | source `=fugitive#buffer().repo().dir('fugitive.vim')` | endif | |
autocmd BufNewFile */init.d/* | |
\ if filereadable("/etc/init.d/skeleton") | | |
\ 0r /etc/init.d/skeleton | | |
\ $delete | | |
\ silent! execute "%s/\\$\\(Id\\):[^$]*\\$/$\\1$/eg" | | |
\ endif | | |
\ set ft=sh | 1 | |
autocmd BufNewFile */.netrc,*/.fetchmailrc,*/.my.cnf let b:chmod_new="go-rwx" | |
autocmd BufNewFile * let b:chmod_exe=1 | |
autocmd BufWritePre * if exists("b:chmod_exe") | | |
\ unlet b:chmod_exe | | |
\ if getline(1) =~ '^#!' | let b:chmod_new="+x" | endif | | |
\ endif | |
autocmd BufWritePost,FileWritePost * if exists("b:chmod_new")| | |
\ silent! execute "!chmod ".b:chmod_new." <afile>"| | |
\ unlet b:chmod_new| | |
\ endif | |
autocmd BufWritePost,FileWritePost ~/.Xdefaults,~/.Xresources silent! !xrdb -load % >/dev/null 2>&1 | |
autocmd BufWritePre,FileWritePre /etc/* if &ft == "dns" | | |
\ exe "normal msHmt" | | |
\ exe "gl/^\\s*\\d\\+\\s*;\\s*Serial$/normal ^\<C-A>" | | |
\ exe "normal g`tztg`s" | | |
\ endif | |
autocmd BufReadPre *.pdf setlocal binary | |
autocmd BufReadCmd *.jar call zip#Browse(expand("<amatch>")) | |
autocmd FileReadCmd *.doc execute "read! antiword \"<afile>\"" | |
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave * | |
\ if isdirectory(expand("<amatch>:h")) | let &swapfile = &modified | endif | |
augroup END " }}}2 | |
augroup FTCheck " {{{2 | |
autocmd! | |
autocmd BufNewFile,BufRead */apache2/[ms]*-*/* set ft=apache | |
autocmd BufNewFile,BufRead *named.conf* set ft=named | |
autocmd BufNewFile,BufRead *.cl[so],*.bbl set ft=tex | |
autocmd BufNewFile,BufRead /var/www/*.module set ft=php | |
autocmd BufNewFile,BufRead *.vb set ft=vbnet | |
autocmd BufNewFile,BufRead *.CBL,*.COB,*.LIB set ft=cobol | |
autocmd BufNewFile,BufRead /var/www/* | |
\ let b:url=expand("<afile>:s?^/var/www/?http://localhost/?") | |
autocmd BufNewFile,BufRead /etc/udev/*.rules set ft=udev | |
" autocmd BufNewFile,BufRead,StdinReadPost * | |
" \ if !did_filetype() && (getline(1) =~ '^!!\@!' | |
" \ || getline(2) =~ '^!!\@!' || getline(3) =~ '^!' | |
" \ || getline(4) =~ '^!' || getline(5) =~ '^!') | | |
" \ setf router | | |
" \ endif | |
autocmd BufRead * if ! did_filetype() && getline(1)." ".getline(2). | |
\ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif | |
autocmd BufNewFile,BufRead *.txt,README,INSTALL,NEWS,TODO if &ft == ""|set ft=text|endif | |
augroup END " }}}2 | |
augroup FTOptions " {{{2 | |
autocmd! | |
autocmd FileType c,cpp,cs,java setlocal ai et sta sw=4 sts=4 cin | |
autocmd FileType go setlocal ai et sta sw=8 sts=8 cin | |
autocmd FileType sh,csh,tcsh,zsh setlocal ai et sta sw=4 sts=4 | |
autocmd FileType tcl,perl,python setlocal ai et sta sw=4 sts=4 | |
autocmd FileType json setlocal ai et sta sw=4 sts=4 | |
autocmd FileType markdown,liquid setlocal ai et sta sw=2 sts=2 tw=72 | |
autocmd FileType javascript setlocal ai et sta sw=2 sts=2 ts=2 cin isk+=$ | |
autocmd FileType php,aspperl,aspvbs,vb setlocal ai et sta sw=4 sts=4 | |
autocmd FileType apache,sql,vbnet setlocal ai et sta sw=4 sts=4 | |
autocmd FileType tex,css,scss setlocal ai et sta sw=2 sts=2 | |
autocmd FileType html,xhtml,wml,cf setlocal ai et sta sw=2 sts=2 | |
autocmd FileType xml,xsd,xslt setlocal ai et sta sw=2 sts=2 ts=2 | |
autocmd FileType eruby,yaml,ruby setlocal ai et sta sw=2 sts=2 "foldmethod=syntax | |
autocmd FileType cucumber setlocal ai et sta sw=2 sts=2 ts=2 | |
autocmd FileType text,txt,mail setlocal ai com=fb:*,fb:-,n:> | |
autocmd FileType sh,zsh,csh,tcsh inoremap <silent> <buffer> <C-X>! #!/bin/<C-R>=&ft<CR> | |
autocmd FileType perl,python,ruby inoremap <silent> <buffer> <C-X>! #!/usr/bin/<C-R>=&ft<CR> | |
autocmd FileType sh,zsh,csh,tcsh,perl,python,ruby imap <buffer> <C-X>& <C-X>!<Esc>o <C-U># $I<C-V>d$<Esc>o <C-U><C-X>^<Esc>o <C-U><C-G>u | |
autocmd FileType c,cpp,cs,java,perl,javscript,php,aspperl,tex,css let b:surround_101 = "\r\n}" | |
autocmd User ragtag if &sw == 8 | setlocal sw=2 sts=2 ts=2 | endif | |
autocmd FileType apache setlocal commentstring=#\ %s | |
autocmd FileType aspvbs,vbnet setlocal comments=sr:'\ -,mb:'\ \ ,el:'\ \ ,:',b:rem formatoptions=crq | |
autocmd FileType asp* runtime! indent/html.vim | |
autocmd FileType bst setlocal ai sta sw=2 sts=2 | |
autocmd FileType cobol setlocal ai et sta sw=4 sts=4 tw=72 makeprg=cobc\ -x\ -Wall\ % | |
autocmd FileType cs silent! compiler cs | setlocal makeprg=gmcs\ % | |
autocmd FileType css silent! setlocal omnifunc=csscomplete#CompleteCSS | |
autocmd FileType cucumber silent! compiler cucumber | setl makeprg=cucumber\ "%:p" | imap <buffer><expr> <Tab> pumvisible() ? "\<C-N>" : (CucumberComplete(1,'') >= 0 ? "\<C-X>\<C-O>" : (getline('.') =~ '\S' ? ' ' : "\<C-I>")) | |
autocmd FileType git,gitcommit setlocal foldmethod=syntax foldlevel=1 | |
autocmd FileType gitcommit setlocal spell | |
autocmd FileType gitrebase nnoremap <buffer> S :Cycle<CR> | |
autocmd FileType help setlocal ai fo+=2n | silent! setlocal nospell | |
autocmd FileType help nnoremap <silent><buffer> q :q<CR> | |
autocmd FileType html setlocal iskeyword+=~ | |
autocmd FileType java silent! compiler javac | setlocal makeprg=javac\ % | |
autocmd FileType mail if getline(1) =~ '^[A-Za-z-]*:\|^From ' | exe 'norm gg}' |endif|silent! setlocal spell | |
autocmd FileType perl silent! compiler perl | |
autocmd FileType pdf setlocal foldmethod=syntax foldlevel=1 | |
autocmd FileType ruby setlocal tw=79 isfname+=: comments=:#\ " | let &includeexpr = 'tolower(substitute(substitute('.&includeexpr.',"\\(\\u\\+\\)\\(\\u\\l\\)","\\1_\\2","g"),"\\(\\l\\|\\d\\)\\(\\u\\)","\\1_\\2","g"))' | |
autocmd FileType ruby | |
\ if expand('%') =~# '_test\.rb$' | | |
\ compiler rubyunit | setl makeprg=testrb\ \"%:p\" | | |
\ elseif expand('%') =~# '_spec\.rb$' | | |
\ compiler rspec | setl makeprg=rspec\ \"%:p\" | | |
\ else | | |
\ compiler ruby | setl makeprg=ruby\ -wc\ \"%:p\" | | |
\ endif | |
autocmd User Bundler if &makeprg !~ 'bundle' | setl makeprg^=bundle\ exec\ | endif | |
autocmd FileType text,txt setlocal tw=78 linebreak nolist | |
autocmd FileType tex silent! compiler tex | setlocal makeprg=latex\ -interaction=nonstopmode\ % formatoptions+=l | |
autocmd FileType tex if exists("*IMAP")| | |
\ call IMAP('{}','{}',"tex")| | |
\ call IMAP('[]','[]',"tex")| | |
\ call IMAP('{{','{{',"tex")| | |
\ call IMAP('$$','$$',"tex")| | |
\ call IMAP('^^','^^',"tex")| | |
\ call IMAP('::','::',"tex")| | |
\ call IMAP('`/','`/',"tex")| | |
\ call IMAP('`"\','`"\',"tex")| | |
\ endif | |
autocmd FileType vbnet runtime! indent/vb.vim | |
autocmd FileType vim setlocal ai et sta sw=2 sts=2 keywordprg=:help | |
autocmd FileType * if exists("+omnifunc") && &omnifunc == "" | setlocal omnifunc=syntaxcomplete#Complete | endif | |
autocmd FileType * if exists("+completefunc") && &completefunc == "" | setlocal completefunc=syntaxcomplete#Complete | endif | |
augroup END "}}}2 | |
endif " has("autocmd") | |
" Copy to Lodgeit on ^L | |
" --------------------- | |
map <C-n> :NERDTreeToggle<CR> | |
Plugin 'airblade/vim-gitgutter' | |
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a | |
function! s:align() | |
let p = '^\s*|\s.*\s|\s*$' | |
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) | |
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) | |
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) | |
Tabularize/|/l1 | |
normal! 0 | |
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment