Skip to content

Instantly share code, notes, and snippets.

@nowk
Last active December 12, 2015 04:18
Show Gist options
  • Save nowk/4713119 to your computer and use it in GitHub Desktop.
Save nowk/4713119 to your computer and use it in GitHub Desktop.
set t_Co=256
set shell=bash
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
if filereadable(expand('~/.vim/Vunfile'))
source ~/.vim/Vunfile
endif
if filereadable(expand('~/.vim/vimrc.local'))
source ~/.vim/vimrc.local
endif
set runtimepath^=~/.vim/bundle/ctrlp.vim
filetype plugin indent on " required!
syntax on " required!
",V reloads it -- making all changes active (have to save first)
map <silent> ,V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
if has("autocmd")
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif
let mapleader = "\\" " \ is the leader character
set t_Co=256
set term=screen-256color
set lazyredraw
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set nobackup
set nowritebackup
set history=1000 " keep 1000 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set clipboard=unnamed " yank to system clipboard
" set spell
" set spellsuggest=3
set hidden
" disable arrow keys
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
" # /mouse
set mouse=a
set ttymouse=xterm2
" set selectmode=mouse
" # / Softtabs, 2 spaces
set ts=2 sts=2 sw=2 expandtab
set autoindent
set smarttab
set smartindent
" # /code folding http://smartic.us/2009/04/06/code-folding-in-vim/
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1
" # /balloons
" not going to work within terminal
" set ballooneval
" # /style
set list listchars=tab:»·,trail:·
set linespace=2
set guioptions-=L
set guioptions-=r
set guioptions-=T
set guifont=Anonymous:h11
set background=light "dark
" colorscheme molokai
colorscheme github
" colorscheme Tomorrow-Night
" if exists('+colorcolumn')
" set colorcolumn=80
" else
" au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
" endif
" set colorcolumn=80
" set cursorcolumn
" set cursorline
set nocursorcolumn
set nocursorline
set hlsearch
set number
" highlight Normal ctermbg=232
" highlight NonText ctermbg=232
" highlight ColorColumn ctermbg=234
" " highlight CursorColumn ctermbg=233 cterm=NONE
" " highlight CursorLine ctermbg=233
" highlight LineNr ctermbg=233 ctermfg=239 cterm=BOLD
" highlight Search ctermbg=228 ctermfg=000 cterm=NONE
" " highlight SpellBad ctermbg=131 cterm=underline
" highlight Visual ctermbg=111 ctermfg=000
" nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
map <leader>h :set invhls <CR>
nnoremap <C-L> :nohls<CR><C-L>
inoremap <C-L> <C-O>:nohls<CR>
" statusline
if filereadable(expand('~/.vim/vimrc.statusline'))
source ~/.vim/vimrc.statusline
endif
" Press Shift+P while in visual mode to replace the selection without
" overwriting the default register
vmap P p :call setreg('"', getreg('0')) <CR>
" e shortcuts
map ,e :e <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,et :tabe <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,es :split <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,ev :vsplit <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,mkd :!mkdir <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,mv :!mv <C-R>=escape(expand("%"), '\ ')<CR> <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,cp :!cp <C-R>=escape(expand("%"), '\ ')<CR> <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,sa :saveas <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
" insert time
map ,time :normal a<c-r>=strftime('%F %H:%M:%S.0 %z')<cr>
" # /run-ruby [Similar to TM's cmd+r]
map ,r :w !ruby<CR>
map ,n :w !node<CR>
map <leader>mo :w !mocha --reporter list<CR>
map <leader>mm :w !mocha <C-R>% --reporter list<CR>
map <leader>nu :w !nodeunit<CR>
map <leader>nn :w !nodeunit <C-R>%<CR>
" # /compile-less
" nnoremap ,m :w <BAR> !lessc % > %:t:r.css<CR><space>
" http://robots.thoughtbot.com/post/619330025/viiiiiiiiiiiiiiiiiim
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>:retab<CR>
map <silent> <C-h> ^cw
vmap D y'>p
" define file type
au BufNewFile,BufRead *.hamlc set filetype=haml
au BufNewFile,BufRead Vunfile set filetype=vim
" au FileType javascript call JavaScriptFold()
" Mappings to find TODOs and stuff
nnoremap ,td :noautocmd vimgrep /TODO/j **/*.rb<CR>:cw<CR>
nnoremap ,fm :noautocmd vimgrep /FIXME/j **/*.rb<CR>:cw<CR>
nnoremap ,bg :noautocmd vimgrep /BUG/j **/*.rb<CR>:cw<CR>
" MUST disable iterms CMD+r, it refreshes view and screws everything up
" afterwards
" map <D-r> <Nop>
" syntax sync minlines=256
" ---------------------------------------------------------------------------- "
" Plugin settings "
" ---------------------------------------------------------------------------- "
" NERDTree
nmap <silent> <leader>p :NERDTreeToggle<CR>
nmap <silent> <leader>b :NERDTreeFromBookmark<CR>
" snipMate
ino <s-tab> <c-r>=TriggerSnippet()<cr>
snor <s-tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
" Syntastic
" let g:syntastic_enable_signs = 1
" let g:syntastic_auto_loc_list = 0
" let g:syntastic_loc_list_height = 4
" let g:syntastic_quiet_warnings = 1
" let g:syntastic_auto_jump = 1
" let g:syntastic_enable_highlighting = 1
" let g:syntastic_javascript_checker = 'jshint' " npm install jshint -g
" let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
" Zenconding
" ctr+y+,
let g:user_zen_settings = {
\ 'indentation' : ' ',
\ 'php' : {
\ 'extends' : 'html',
\ },
\ 'xml' : {
\ 'extends' : 'html',
\ },
\ 'erb' : {
\ 'extends' : 'html',
\ },
\ 'haml' : {
\ 'extends' : 'html',
\ },
\ 'rhtml' : {
\ 'extends' : 'html',
\ },
\}
" flog
" silent exe 'g:flog_enable'
" silent exe 'hi low_complexity ctermfg=229'
" silent exe 'hi medium_complexity ctermfg=208'
" silent exe 'hi high_complexity ctermfg=196'
" silent exe 'hi SignColumn ctermfg=232'
function! RubyTestWithZeus()
return findfile(".zeus.sock") == ".zeus.sock" ? 'zeus' : ''
endfunction
" vim-rubytest
let g:rubytest_in_quickfix = 0
let g:rubytest_cmd_spec = "bundle exec rspec %p"
let g:rubytest_cmd_spec_example = "bundle exec rspec %p:'%c'"
let g:rubytest_cmd_rspec = "bundle exec rspec %p"
let g:rubytest_cmd_rspec_example = "bundle exec rspec %p:'%c'"
let g:rubytest_cmd_feature = "bundle exec rspec %"
let g:rubytest_cmd_story = "bundle exec rspec % --example '%c'"
" map ,t <Plug>RubyTestRun
" map ,T <Plug>RubyFileRun
" map ,rt <Plug>RubyTestRunLast
map <leader>] <Plug>RubyTestRun
map <leader>} <Plug>RubyFileRun
map <leader>[ <Plug>RubyTestRunLast
"
"
map ,dt :call DefaultTheme()<CR>
map ,gt :call GithubTheme()<CR>
function! DefaultTheme()
colorscheme molokai
set background=dark
hi cursorline ctermbg=234
hi Comment ctermfg=239 cterm=BOLD
endfunction
function! GithubTheme()
colorscheme github
set background=light
hi cursorline ctermbg=255
hi Comment ctermfg=251 cterm=BOLD
" hi ExtraWhitespace ctermbg=211
endfunction
call GithubTheme()
" map ,t :call RunSpecFile()<CR>
" map ,s :call RunNearestSpec()<CR>
" map ,l :call RunLastSpec()<CR>
"
" function! RunSpecFile()
" if InSpecFile()
" let t:last_spec_file_command = "bundle exec rspec " . @% . " -f documentation"
" endif
"
" call RunLastSpecFile()
" endfunction
"
" function! RunNearestSpec()
" if InSpecFile()
" let t:last_nearest_spec_command = "bundle exec rspec " . @% . " -l " . line(".") . " -f documentation"
" endif
"
" call RunLastNearestSpec()
" endfunction
"
" function! RunLastSpec()
" call RunSpecs()
" endfunction
"
" function! InSpecFile()
" return match(expand("%"), "_spec.rb$") != -1
" endfunction
"
" function! RunLastNearestSpec()
" if exists("t:last_nearest_spec_command")
" call SetLastSpecCommand(t:last_nearest_spec_command)
" call RunSpecs()
" endif
" endfunction
"
" function! RunLastSpecFile()
" if exists("t:last_spec_file_command")
" call SetLastSpecCommand(t:last_spec_file_command)
" call RunSpecs()
" endif
" endfunction
"
" function! RunSpecs()
" if exists("t:last_spec_command")
" execute ":w\|!clear && echo " . t:last_spec_command . " && echo && " . t:last_spec_command
" endif
" endfunction
"
" function! SetLastSpecCommand(command)
" let t:last_spec_command = a:command
" endfunction
" tabular
" if exists(":Tabularize")
" nmap a= :Tabularize /=<CR>
" vmap a= :Tabularize /=<CR>
" nmap a: :Tabularize /:\zs<CR>
" vmap a: :Tabularize /:\zs<CR>
" endif
" tag list
nnoremap <silent> <F8> :TlistToggle<CR>
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_regexp = 1
let g:ctrlp_open_new_file = 'r'
let g:ctrlp_max_height = 15
let g:ctrlp_match_window_reversed = 1
let g:ctrlp_reuse_window = 'netrw\|nerdtree'
let g:ctrlp_switch_buffer = 0
set wildignore+=*/tmp/*,*/node_modules/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" let g:ctrlp_custom_ignore = {
" \ 'dir': '\v[\/]\.(git|hg|svn)$',
" \ 'file': '\v\.(exe|so|dll)$',
" \ 'link': 'some_bad_symbolic_links'
" \ }
" status line
" Always display the status line
set laststatus=2
" Mode based color coding of status line
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline ctermbg=red ctermfg=white cterm=BOLD
" set paste " TODO this puts i into paste mode and kills syntax tab
" completion. Have to set nopaste to get it all back.
elseif a:mode == 'r'
hi statusline ctermbg=blue
else
hi statusline ctermbg=green
endif
endfunction
function! InsertLeaveActions()
hi statusline ctermbg=green ctermfg=black cterm=NONE
set nopaste
set nocursorcolumn
endfunction
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * call InsertLeaveActions()
inoremap <c-c> <c-o>:call InsertLeaveActions()<cr><c-c>
" default the statusline to colors
hi statusline ctermbg=cyan ctermfg=black cterm=NONE
set statusline=%F%m%r%h%w\ FORMAT:%{&ff}\ \/\ %Y\ [-L=%04l\ -C=%04v\ -ASCII=\%03.3b\ -HEX=\%02.2B]\ [%p%%]\ [LEN=%L]
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
" Theme
"
Bundle 'molokai'
Bundle 'croaky/vim-colors-github'
" Required utilities
"
Bundle 'kien/ctrlp.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'airblade/vim-rooter'
Bundle 'godlygeek/tabular'
Bundle 'Raimondi/delimitMate'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'henrik/vim-markdown-preview'
Bundle 'ervandew/supertab'
" Bundle 'fousa/vim-flog'
" Ruby
"
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rake'
Bundle 'tpope/vim-bundler'
Bundle 'nowk/vim-rubytest'
" Bundle 'tpope/vim-cucumber'
" Bundle 'tpope/vim-liquid'
" Bundle 'sunaku/vim-ruby-minitest'
" Bundle 'vim-scripts/rubycomplete.vim'
" Javascript
"
Bundle 'moll/vim-node'
Bundle 'digitaltoad/vim-jade'
" Bundle 'jelera/vim-javascript-syntax'
" HTML/CSS
"
Bundle 'mattn/emmet-vim'
" Syntax
"
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
Bundle 'garbas/vim-snipmate'
Bundle 'honza/vim-snippets'
Bundle 'scrooloose/syntastic'
Bundle 'vim-scripts/taglist.vim'
" Git
"
" Bundle 'mattn/gist-vim'
" Bundle 'mattn/webapi-vim'
" Tpope
"
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-ragtag'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-commentary'
" Bundle 'tpope/vim-abolish'
" Bundle 'tpope/vim-haml'
" Bundle 'tpope/vim-speeddating'
" Bundle 'tpope/vim-markdown'
" Unsure (keep just in case)
"
" Bundle 'kchmck/vim-coffee-script.git'
" Bundle 'groenewege/vim-less'
" Bundle 'hallison/vim-ruby-sinatra'
" Bundle 'clones/vim-l9'
" Bundle 'mileszs/ack.vim'
" Bundle 'leshill/vim-json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment