Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sync to latest cb vim config

  • Loading branch information...
commit f397ca4544d8ec4a04ab420f279fadef0525a43e 1 parent ddb0411
Ben Moss & Sean Moon authored
View
35 .gitmodules
@@ -34,3 +34,38 @@
[submodule "bundle/command-t"]
path = bundle/command-t
url = git://git.wincent.com/command-t.git
+[submodule "bundle/vim-abolish"]
+ path = bundle/vim-abolish
+ url = https://github.com/tpope/vim-abolish.git
+[submodule "bundle/vim-javascript"]
+ path = bundle/vim-javascript
+ url = https://github.com/pangloss/vim-javascript.git
+[submodule "bundle/vim-colors-solarized"]
+ path = bundle/vim-colors-solarized
+ url = git://github.com/altercation/vim-colors-solarized.git
+[submodule "bundle/vim-fugitive"]
+ path = bundle/vim-fugitive
+ url = https://github.com/tpope/vim-fugitive.git
+[submodule "bundle/vim-git-pair"]
+ path = bundle/vim-git-pair
+ url = https://github.com/Peeja/vim-git-pair.git
+[submodule "bundle/vim-markdown"]
+ path = bundle/vim-markdown
+ url = https://github.com/plasticboy/vim-markdown.git
+[submodule "bundle/vim-ruby-refactoring"]
+ path = bundle/vim-ruby-refactoring
+ url = https://github.com/ecomba/vim-ruby-refactoring.git
+[submodule "bundle/vim-textobj-rubyblock"]
+ path = bundle/vim-textobj-rubyblock
+ url = https://github.com/nelstrom/vim-textobj-rubyblock.git
+[submodule "bundle/vim-textobj-user"]
+ path = bundle/vim-textobj-user
+ url = https://github.com/kana/vim-textobj-user.git
+[submodule "bundle/vim-unimpaired"]
+ path = bundle/vim-unimpaired
+ url = https://github.com/tpope/vim-unimpaired.git
+[submodule "bundle/vim-irblack"]
+ path = bundle/vim-irblack
+ url = https://github.com/wgibbs/vim-irblack.git
+
+
1  bundle/vim-abolish
@@ -0,0 +1 @@
+Subproject commit 119b515d48ae6181785cacded179b6379368ed5c
1  bundle/vim-javascript
@@ -0,0 +1 @@
+Subproject commit 91540f635bb8869e7243596f10de0e673c22d3a6
2  bundle/vim-rails
@@ -1 +1 @@
-Subproject commit dcae61e521f953ed8b29af8937b89b7fded67d6a
+Subproject commit f989257187c523af351d5143ec79f2fe0322cd84
View
4 snippets/javascript.snippets
@@ -14,6 +14,6 @@ snippet con
${2}
});
snippet bef
- beforeEach("${1}", function() {
- ${2}
+ beforeEach(function() {
+ ${1}
});
View
168 vimrc
@@ -1,7 +1,8 @@
"pathogen setup
-filetype off
-call pathogen#helptags()
-call pathogen#runtime_append_all_bundles()
+ filetype on
+ filetype off
+ call pathogen#helptags()
+ call pathogen#runtime_append_all_bundles()
"see vim-rails plugin doc [rails.txt]
set nocompatible
@@ -47,12 +48,17 @@ map \ :NERDTreeToggle<CR>
map \| :NERDTreeFind<CR>
"strip trailing whitespace on save for code files
+function! StripTrailingWhitespace()
+ let save_cursor = getpos(".")
+ %s/\s\+$//e
+ call setpos('.', save_cursor)
+endfunction
"cocoa
-autocmd BufWritePre *.m,*.h,*.c,*.mm,*.cpp,*.hpp :%s/\s\+$//e
+autocmd BufWritePre *.m,*.h,*.c,*.mm,*.cpp,*.hpp call StripTrailingWhitespace()
"rails
-autocmd BufWritePre *.rb,*.yml,*.js,*.json,*.css,*.less,*.sass,*.html,*.xml,*.erb,*.haml :%s/\s\+$//e
+autocmd BufWritePre *.rb,*.yml,*.js,*.css,*.less,*.sass,*.scss,*.html,*.xml,*.erb,*.haml call StripTrailingWhitespace()
"misc
-autocmd BufWritePre *.java,*.php,*.feature :%s/\s\+$//e
+autocmd BufWritePre *.java,*.php,*.feature call StripTrailingWhitespace()
"highlight JSON files as javascript
autocmd BufRead,BufNewFile *.json set filetype=javascript
@@ -68,7 +74,7 @@ set background=dark
"Show whitespace, fullstops for trailing whitespace
set list
-set listchars=trail:.
+set listchars=trail:·
"Keep backup files somewhere else
set backupdir=~/.vim-tmp,~/tmp,/var/tmp,/tmp
@@ -113,6 +119,9 @@ set shiftwidth=2
set autoindent
set expandtab
+" Allow backspace to work more flexibly.
+set backspace=2
+
" Rayban & Peter
let mapleader = ","
@@ -153,15 +162,18 @@ autocmd FileType scss set iskeyword=@,48-57,_,-,?,!,192-255
" Insert ' => '
autocmd FileType ruby imap <Space>=><Space>
+" Open all folds in Markdown.
+autocmd FileType mkd normal zR
+
" reload .vimrc
map <leader>rv :source ~/.vimrc<CR>
" refresh the FuzzyFinder cache
map <leader>rf :FufRenewCache<CR>
-" ctags again with gemhome added
-map <leader>t :!/usr/local/bin/ctags -R --exclude=.git --exclude=log * `rvm gemhome`/*<CR>
-map <leader>T :!rdoc -f tags -o tags * `rvm gemhome` --exclude=.git --exclude=log
+" ctags with rails load path
+map <leader>t :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs /usr/local/bin/ctags -R public/javascripts<CR>
+map <leader>T :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs rdoc -f tags<CR>
" git blame
map <leader>g :Gblame<CR>
@@ -170,7 +182,7 @@ map <leader>g :Gblame<CR>
map <silent> <F7> mzgg=G'z :delmarks z<CR>:echo "Reformatted."<CR>
" Write all writeable buffers when changing buffers or losing focus.
-autocmd FocusLost * silent! wall
+autocmd BufLeave,FocusLost * silent! wall
set autowriteall
" Let unsaved buffers exist in the background.
@@ -186,6 +198,49 @@ imap <D-CR> <ESC>o
" Change background color when inserting.
let g:insert_mode_background_color = "#18434E"
+" Run a test tool with the current file and line number
+" The test tool is run in the last Terminal window
+function! RunTestTool(tool_cmd)
+ let dir = system('pwd')
+ let applescript = "osascript -e '".'tell application "Terminal"'
+ let applescript .= "\n"
+ let applescript .= 'do script "cd '.dir.'" in last window'
+ let applescript .= "\n"
+ let applescript .= 'do script "'.a:tool_cmd.'" in last window'
+ let applescript .= "\n"
+ let applescript .= 'end tell'."'"
+ let foo = system(applescript)
+endfunction
+
+" If the file ends with _spec.rb, RunTestTool with rspec
+" If the file ends with .feature, RunTestTool with cuke
+command! RunFocusedTest :call RunFocusedTest()
+function! RunFocusedTest()
+ let filename = expand("%")
+ if filename =~ '_spec\.rb$'
+ call RunTestTool("be rspec ".expand("%").":".line("."))
+ endif
+ if filename =~ '\.feature$'
+ call RunTestTool("cuke ".expand("%").":".line("."))
+ endif
+endfunction
+
+command! RunTests :call RunTests()
+function! RunTests()
+ let filename = expand("%")
+ if filename =~ '_spec\.rb$'
+ call RunTestTool("be rspec ".expand("%"))
+ endif
+ if filename =~ '\.feature$'
+ call RunTestTool("cuke ".expand("%"))
+ endif
+endfunction
+
+" Run test at cursor
+map <leader><D-R> :w<CR>:RunFocusedTest<CR>
+" Run all tests in file
+map <leader><D-r> :w<CR>:RunTests<CR>
+
" Find unused cucumber steps.
command! CucumberFindUnusedSteps :call CucumberFindUnusedSteps()
function! CucumberFindUnusedSteps()
@@ -204,6 +259,7 @@ map <D-<> :tabedit ~/.vimrc<CR>
" Make command completion act more like bash
set wildmode=list:longest
+cmap <C-A> <C-B>
" Start scrolling when the cursor is within 3 lines of the edge.
set scrolloff=3
@@ -220,6 +276,7 @@ map <leader>/ <plug>NERDCommenterToggle
" Copy current file path to system pasteboard.
map <silent> <D-C> :let @* = expand("%")<CR>:echo "Copied: ".expand("%")<CR>
+map <leader>C :let @* = expand("%").":".line(".")<CR>:echo "Copied: ".expand("%").":".line(".")<CR>
" Disable middle mouse button (which is easy to hit by accident).
map <MiddleMouse> <Nop>
@@ -231,9 +288,10 @@ map Y y$
" Don't time out during commands.
set notimeout
-" Turn off <F1>
+" Turn off <F1> and double-click for new tab.
map <F1> <Nop>
imap <F1> <Nop>
+map <2-LeftMouse> <Nop>
" Don't prompt for file changes outside MacVim
set autoread
@@ -241,25 +299,87 @@ set autoread
" Highlight current row.
set cursorline
-" Use paste mode when replacing. (Work in progress.)
-" vmap <silent> <C-K> :<C-U>call InPasteMode("<Plug>ReplaceVisual")<CR>
-" function! InPasteMode(command)
- " let oldpaste = &l:paste
- " try
- " set paste
- " execute "normal" "gv".a:command
- " finally
- " let &l:paste = oldpaste
- " endtry
-" endfunction
-
" Command-T
let g:CommandTMaxHeight=20
map <D-N> :CommandTFlush<CR>:CommandT<CR>
+map <Leader>f :CommandTFlush<CR>:CommandT<CR>
" Easy access to the shell.
map <Leader><Leader> :!
+" Rename tabs to show tab number.
+" (Based on http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function)
+if exists("+showtabline")
+ function! MyTabLine()
+ let s = ''
+ let wn = ''
+ let t = tabpagenr()
+ let i = 1
+ while i <= tabpagenr('$')
+ let buflist = tabpagebuflist(i)
+ let winnr = tabpagewinnr(i)
+ let s .= '%' . i . 'T'
+ let s .= (i == t ? '%1*' : '%2*')
+ let s .= ' '
+ let wn = tabpagewinnr(i,'$')
+
+ let s .= '%#TabNum#'
+ let s .= i
+ " let s .= '%*'
+ let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
+ let bufnr = buflist[winnr - 1]
+ let file = bufname(bufnr)
+ let buftype = getbufvar(bufnr, 'buftype')
+ if buftype == 'nofile'
+ if file =~ '\/.'
+ let file = substitute(file, '.*\/\ze.', '', '')
+ endif
+ else
+ let file = fnamemodify(file, ':p:t')
+ endif
+ if file == ''
+ let file = '[No Name]'
+ endif
+ let s .= ' ' . file . ' '
+ let i = i + 1
+ endwhile
+ let s .= '%T%#TabLineFill#%='
+ let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
+ return s
+ endfunction
+ set stal=2
+ set tabline=%!MyTabLine()
+endif
+
+set showtabline=1
+
+highlight link TabNum Special
+
+
+" surround.vim: Add $ as a jQuery surround, _ for Underscore.js
+autocmd FileType javascript let b:surround_36 = "$(\r)"
+ \ | let b:surround_95 = "_(\r)"
+
+" To use:
+" let g:i = 0
+" %s/foo/\="id: ".AutoincrementI()
+"
+" foo -> id: 1
+" foo -> id: 2
+function! AutoincrementI()
+ let g:i = g:i + 1
+ return g:i
+endfunction
+
+" Map Cmd-S to <F12> in iTerm2 for Save.
+map <F12> :w<CR>
+map! <F12> <C-o>:w<CR>
+
+map <F11> :q<CR>
+map! <F11> <C-o>:q<CR>
+
+map <Esc>[A <Up>
+
" (Keep this at the end.)
" Machine-local vim settings.
silent source ~/.vimrc.local
Please sign in to comment.
Something went wrong with that request. Please try again.