Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mcfiredrill/0dd1d55339e8ea562ffabd3321b48d66 to your computer and use it in GitHub Desktop.

Select an option

Save mcfiredrill/0dd1d55339e8ea562ffabd3321b48d66 to your computer and use it in GitHub Desktop.
.vimrc
"NeoBundle Scripts-----------------------------
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=/Users/tony/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('/Users/tony/.vim/bundle'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
NeoBundle 'Shougo/neosnippet.vim'
NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'flazz/vim-colorschemes'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-rails'
NeoBundle 'tpope/vim-endwise'
NeoBundle 'tpope/vim-eunuch'
NeoBundle 'tpope/vim-cucumber'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'chriskempson/vim-tomorrow-theme'
NeoBundle 'tomtom/tcomment_vim'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'nono/vim-handlebars'
NeoBundle 'rking/ag.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'elixir-lang/vim-elixir'
NeoBundle 'Valloric/MatchTagAlways'
NeoBundle 'mtth/scratch.vim'
NeoBundle 'Keithbsmiley/swift.vim'
NeoBundle 'junkblocker/git-time-lapse'
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End NeoBundle Scripts-------------------------
"γ‚€γ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺγ‚ͺ
"set encoding=utf8
set autoindent
"some systems require set syntax=on, some require syntax on
"set syntax=on
syntax on
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" tabs and spaces junk
set sts=2
set shiftwidth=2
set expandtab "use spaces for tabs
"set noexpandtab "use tabs for tabs
set smarttab
set smartindent
"use 4 spaces for some types of files
au FileType c setl sts=4 shiftwidth=4
au FileType cpp setl sts=4 shiftwidth=4
au FileType java setl sts=4 shiftwidth=4
au FileType php setl ts=2 noexpandtab
au FileType go setl noexpandtab sts=4 ts=4 shiftwidth=4
au BufRead,BufNewFile *.md setlocal textwidth=80
au BufRead,BufNewFile *.eye set filetype=ruby
set ruler
set hls
set ruler
set makeprg=make
" for CSApprox (256 colors for colorschemes)
set t_Co=256
set background=dark
set incsearch
let c_space_errors=1
" Reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
if filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
color solarized " load a colorscheme
endif
let g:solarized_termtrans=1
let g:solarized_contrast="high"
let g:solarized_visibility="high"
"colorscheme solarized
colorscheme Tomorrow-Night-Eighties
set noswapfile "NO SWAPFILES. EVER. DONE.
let mapleader = ","
set number
set relativenumber
"set paste
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" some autocmd stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ARROW KEYS ARE UNACCEPTABLE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROMOTE VARIABLE TO RSPEC LET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" function! PromoteToLet()
" :normal! dd
" " :exec '?^\s*it\>'
" :normal! P
" :.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
" :normal ==
" endfunction
" :command! PromoteToLet :call PromoteToLet()
" :map <leader>p :PromoteToLet<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>y "*y
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" " Clear the search buffer when hitting return
function! MapCR()
nnoremap <cr> :nohlsearch<cr>
endfunction
call MapCR()
nnoremap <leader><leader> <c-^>
map <leader>w :w<cr>
"------------------------------------------------------------
" CtrlP
"------------------------------------------------------------
" Set the max files
" let g:ctrlp_max_files = 10000
"
" " Optimize file searching
" if has("unix")
" let g:ctrlp_user_command = {
" \ 'types': {
" \ 1: ['.git/', 'cd %s && git ls-files']
" \ },
" \ 'fallback': 'find %s -type f | head -' . g:ctrlp_max_files
" \ }
" endif
"
" map <leader>p :CtrlP<cr>
" ctrl+p - ish mapping for unite
" nnoremap <C-p> :Unite file_rec/async<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>t :call RunTestFile()<cr>
map <leader>T :call RunNearestTest()<cr>
map <leader>a :call RunTests('')<cr>
"map <leader>c :w\|:!script/features<cr>
"map <leader>w :w\|:!script/features --profile wip<cr>
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\|-test.js\)$') != -1
if in_test_file
echom "in test file"
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number . " -b")
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=@%
endfunction
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
if filereadable("script/test")
exec ":!script/test " . a:filename
elseif filereadable("Gemfile")
exec ":!bundle exec rspec --color " . a:filename
elseif filereadable("ember-cli-build.js")
let test = matchlist(getline(line('.')), "^test\('.*',.*$")
echom test[0]
exec ":!ember test --filter" . substitute(test[1], '"', '\\"', 'g')
else
exec ":!rspec --color " . a:filename
end
end
endfunction
"""""""""""""""""""""""""
" ag command
"""""""""""""""""""""""""
map <leader>g :call GrepTextUnderCursor()<CR>
function! GrepTextUnderCursor()
let word_under_cursor = expand("<cword>")
exec ":Ag! " . word_under_cursor
endfunction
"""""""""""""""""""
" quickfix navigate
"""""""""""""""""""
map <leader>r :cnext<cr>
map <leader>q :cnext<cr>
""""""""""""""""""""
" numbers off
""""""""""""""""""""
map <leader>n :set nonumber! norelativenumber!<cr>
"""""""""""""""""""""""""
" display filename always
""""""""""""""""""""""""""
set laststatus=2
" gotta put highlight commands before colorscheme commands! or they may be
" overwritten
"""""""""""""""""""""""""
"" highlight whitespace
"""""""""""""""""""""""""
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
"""""""""""""""""""""""""""""
"" kill all the whitespace
"""""""""""""""""""""""""""""
command -nargs=0 -range=% NukeWhiteSpace <line1>,<line2>s/\s\+$//g
map <leader>N :NukeWhiteSpace<CR>
"""""""""""""""""""""""""""""""""
"" kill whitespace before saving
"""""""""""""""""""""""""""""""""
autocmd BufWritePre * :%s/\s\+$//e
"""""""""""""""""""""""""
"" highlight typos
"""""""""""""""""""""""""
highlight ReceiveTypo ctermbg=red guibg=red
match ReceiveTypo /recieve/
"""""""""""""""""""""""""
"" paste/nopaste
"""""""""""""""""""""""""
" map <leader>p :set paste!<CR>
"
command Gdc Gdiff head
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'eruby' : 1,
\}
" make sure backspace works as expected
set backspace=2 " ???????????????
"" checkmark
" map <leader>c
"" rails routes
map <leader>gr :topleft :split config/routes.rb<cr>
function! ShowRoutes()
" Requires 'scratch' plugin
:topleft 20 :split __Routes__
" Make sure Vim doesn't write __Routes__ as a file
:set buftype=nofile
" Delete everything
:normal 1GdG
" Put routes output in buffer
:0r! rake -s routes
" Size window to number of lines (1 plus rake output length)
:exec ":normal " . line("$") . _ "
" Move cursor to bottom
:normal 1GG
" Delete empty trailing line
:normal dd
endfunction
map <leader>gR :call ShowRoutes()<cr>
nmap <Leader>Gt <Plug>(git-time-lapse)
" from rails.vim, open alternative file in split or vsplit
map <leader>s :AS<cr>
map <leader>v :AV<cr>
set list
set list listchars=tab:\ \ ,trail:πŸ†
"inoremap jk <ESC>
"
"""""""""""""""""""""""""
"" highlight evil quotesβ€œβ€œβ€œβ€œβ€œβ€œβ€œβ€œβ€œ
"""""""""""""""""""""""""
highlight EvilQuotes ctermbg=red guibg=red
match EvilQuotes /β€œ\+/ " β€œ β€œpβ€œβ€œβ€œβ€œβ€œβ€œ
autocmd BufWinEnter * match EvilQuotes /β€œ\+/
autocmd InsertEnter * match EvilQuotes /β€œ\+\%#\@<!/
autocmd InsertLeave * match EvilQuotes /β€œ\+/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment