Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bring in spec-running, etc from thoughtbot vimrc

  • Loading branch information...
commit 3450d71e051a5476fd59fe8fa9de16158c26d5b4 1 parent 377ec8c
Jon Yurek authored
Showing with 53 additions and 1 deletion.
  1. +53 −1 vim/vimrc
54 vim/vimrc
View
@@ -173,4 +173,56 @@ if executable("ag")
endif
" Search the project for the word under the cursor.
-nmap K :grep "\b<C-R><C-W>\b"<CR>:copen<CR>
+nmap K :grep "<C-R><C-W>"<CR>
+autocmd QuickFixCmdPost *grep* cwindow
+
+" Treat <li> and <p> tags like the block tags they are
+let g:html_indent_tags = 'li\|p'
+
+" Markdown files end in .md
+au BufRead,BufNewFile *.md set filetype=markdown
+
+" Enable spellchecking for Markdown
+au BufRead,BufNewFile *.md setlocal spell
+
+" Automatically wrap at 80 characters for Markdown
+au BufRead,BufNewFile *.md setlocal textwidth=80
+
+" rspec mappings
+map <Leader>t :call RunCurrentSpecFile()<CR>
+map <Leader>s :call RunNearestSpec()<CR>
+map <Leader>l :call RunLastSpec()<CR>
+
+function! RunCurrentSpecFile()
+ if InSpecFile()
+ let l:command = "s " . @% . " -f documentation"
+ call SetLastSpecCommand(l:command)
+ call RunSpecs(l:command)
+ endif
+endfunction
+
+function! RunNearestSpec()
+ if InSpecFile()
+ let l:command = "s " . @% . " -l " . line(".") . " -f documentation"
+ call SetLastSpecCommand(l:command)
+ call RunSpecs(l:command)
+ endif
+endfunction
+
+function! RunLastSpec()
+ if exists("t:last_spec_command")
+ call RunSpecs(t:last_spec_command)
+ endif
+endfunction
+
+function! InSpecFile()
+ return match(expand("%"), "_spec.rb$") != -1
+endfunction
+
+function! SetLastSpecCommand(command)
+ let t:last_spec_command = a:command
+endfunction
+
+function! RunSpecs(command)
+ execute ":w\|!echo " . a:command . " && echo && iterm '" . a:command . "'"
+endfunction
Please sign in to comment.
Something went wrong with that request. Please try again.