Skip to content
Browse files

Run tests from MacVim in Terminal session

  • Loading branch information...
1 parent 1a27cbe commit dc36aaf99df52346a4288f00ef854df9afb71579 @vsushkov committed
Showing with 61 additions and 2 deletions.
  1. +49 −2 .vimrc
  2. +2 −0 dottor_rules.yml
  3. +10 −0 run_command
View
51 .vimrc
@@ -80,8 +80,49 @@ fun! StripTrailingWhitespace()
endif
%s/\s\+$//e
endfun
-" UltiSnips settings
-let g:UltiSnipsUsePythonVersion = 2
+
+function! SendToTerminal(args)
+ execute ":silent !run_command '" . a:args . "'"
+endfunction
+
+function! ClearTerminal()
+ call SendToTerminal("clear")
+endfunction
+
+function! RSpec()
+ call ClearTerminal()
+ if exists("s:current_test")
+ call SendToTerminal("rspec -fd " . s:current_test)
+ endif
+endfunction
+
+function! PHPUnit()
+ call ClearTerminal()
+ if exists("s:current_test")
+ call SendToTerminal("phpunit " . s:current_test)
+ endif
+endfunction
+
+function! RunCurrentTest()
+ if exists('b:isPHP')
+ " Coding is requred here
+ let s:current_test = 'UnitTests.php'
+ call PHPUnit()
+ else
+ let s:current_test = expand('%:p')
+ call RSpec()
+ endif
+endfunction
+
+function! RunCurrentLineInTest()
+ let s:current_test = expand('%:p') . ":" . line('.')
+ call RSpec()
+endfunction
+
+function! RunLastCommand()
+ call RSpec()
+endfunction
+
" }}}
" Settings {{{
syntax on
@@ -155,6 +196,7 @@ endif
" Autocommands {{{
autocmd FileType ruby,eruby,yaml setlocal ai sw=2 sts=2 et
autocmd FileType php setlocal ai sw=4 sts=4 et tw=120
+autocmd FileType php let b:isPHP=1
autocmd FileType phptml setlocal ai sw=4 sts=4 et tw=0
autocmd FileType gitcommit setlocal colorcolumn=50,72 tw=72
autocmd FileType md,markdown setlocal colorcolumn=72 tw=72
@@ -250,6 +292,11 @@ imap <C-a> <C-c>A
map Q gqj
nmap <Leader>c :e! ++enc=cp1251 ++ff=dos <CR>
+
+nmap <Leader>u :call RunCurrentTest()<CR>
+" nmap <Leader>l :call RunCurrentLineInTest()<CR>
+" nmap <Leader>rr :call RunLastCommand()<CR>
+
" }}}
" Plugins settings {{{
" Coffe
View
2 dottor_rules.yml
@@ -4,3 +4,5 @@ default:
target: ~/.vimrc
- source: .zshrc
target: ~/.zshrc
+- source: run_command
+ target: ~/bin/run_command
View
10 run_command
@@ -0,0 +1,10 @@
+#!/usr/bin/env osascript
+on run argv
+ tell application "Terminal"
+ do script argv as string in window 1
+ end tell
+
+ tell application "MacVim"
+ activate
+ end tell
+end run

0 comments on commit dc36aaf

Please sign in to comment.
Something went wrong with that request. Please try again.