Skip to content

Commit

Permalink
Merge pull request braintreeps#92 from braintreeps/vim_test
Browse files Browse the repository at this point in the history
Switch to vim-test from homegrown vimux test plugins
  • Loading branch information
pgr0ss authored Jan 26, 2018
2 parents 5a6e15a + 05a502f commit 41b1e8d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 deletions.
6 changes: 3 additions & 3 deletions vim/ftplugin/elixir.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
map <silent> <LocalLeader>ra :wa<CR> :RunAllElixirTests<CR>
map <silent> <LocalLeader>rb :wa<CR> :RunCurrentElixirTests<CR>
map <silent> <LocalLeader>rf :wa<CR> :RunFocusedElixirTests<CR>
map <silent> <LocalLeader>ra :wa<CR> :TestSuite<CR>
map <silent> <LocalLeader>rb :wa<CR> :TestFile<CR>
map <silent> <LocalLeader>rf :wa<CR> :TestNearest<CR>
2 changes: 0 additions & 2 deletions vim/ftplugin/java.vim

This file was deleted.

4 changes: 2 additions & 2 deletions vim/python_mappings.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
map <silent> <LocalLeader>rb :wa<CR> :RunNoseTestBuffer<CR>
map <silent> <LocalLeader>rf :wa<CR> :RunNoseTestFocused<CR>
map <silent> <LocalLeader>rb :wa<CR> :TestFile<CR>
map <silent> <LocalLeader>rf :wa<CR> :TestNearest<CR>
62 changes: 34 additions & 28 deletions vim/ruby_mappings.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
map <silent> <LocalLeader>rb :wa<CR> :call _RunAll()<CR>
map <silent> <LocalLeader>rc :wa<CR> :RunRubyFocusedContext<CR>
map <silent> <LocalLeader>rf :wa<CR> :call _RunLine()<CR>
map <silent> <LocalLeader>rl :wa<CR> :call _RunLast()<CR>
let s:context_start_pattern =
\ '\C^\s*#\@!\s*\%(RSpec\.\)\=\zs' .
\ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin\|def' .
\ '\|\%(public\|protected\|private\)\=\s*def\):\@!\>' .
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'
let s:context_end_pattern = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>'
let s:context_test_pattern =
\ '\C^\s*#\@!\s*\%(RSpec\.\)\=\zs' .
\ '\<\%(describe\|context\|shared_examples\|shared_context\)\>'

function! TestContext()
wall
normal 0
let [_, lnum, cnum, _] = getpos('.')
if getline('.') !~ s:context_test_pattern
let prev_line = line('.')
while line('.') != 1
call searchpair(s:context_start_pattern, '', s:context_end_pattern, 'Wb')
if getline('.') =~ s:context_test_pattern || line('.') == prev_line
break
endif
let prev_line = line('.')
endwhile
endif
TestNearest
call cursor(lnum, cnum)
endfunction

command! TestContext :call TestContext()

map <silent> <LocalLeader>rc :TestContext<CR>
map <silent> <LocalLeader>rb :wa<CR> :TestFile<CR>
map <silent> <LocalLeader>rf :wa<CR> :TestNearest<CR>
map <silent> <LocalLeader>rl :wa<CR> :TestLast<CR>
map <silent> <LocalLeader>rx :wa<CR> :VimuxCloseRunner<CR>
map <silent> <LocalLeader>ri :wa<CR> :VimuxInspectRunner<CR>
map <silent> <LocalLeader>rs :!ruby -c %<CR>
Expand All @@ -21,30 +51,6 @@ function! _BounceInferiorSlime()
endif
endfunction

function! _RunLast()
if _IsInferiorSlimeRunning()
execute "InferiorSlimeSpecLast"
else
execute "VimuxRunLastCommand"
endif
endfunction

function! _RunAll()
if _IsInferiorSlimeRunning()
execute "InferiorSlimeSpecFile"
else
execute "RunAllRubyTests"
endif
endfunction

function! _RunLine()
if _IsInferiorSlimeRunning()
execute "InferiorSlimeSpecLine"
else
execute "RunRubyFocusedTest"
endif
endfunction

function! _IsInferiorSlimeRunning()
if system("ps axo command | grep inferior-slime | grep -v grep") == ""
return 0
Expand Down
3 changes: 3 additions & 0 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ let g:vim_markdown_folding_disabled = 1
let g:go_fmt_command = "goimports"
let g:go_highlight_trailing_whitespace_error = 0

let test#strategy = "vimux"
let test#python#runner = 'nose'

" ========= Shortcuts ========

" NERDTree
Expand Down
6 changes: 1 addition & 5 deletions vimrc.bundles
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Plug 'chase/vim-ansible-yaml'
Plug 'davidzchen/vim-bazel'
Plug 'ddrscott/vim-side-search'
Plug 'derekwyatt/vim-scala'
Plug 'drewolson/vimux-elixir-test'
Plug 'drewolson/vimux-maven-test'
Plug 'ekalinin/Dockerfile.vim'
Plug 'elixir-lang/vim-elixir'
Plug 'elubow/cql-vim'
Expand All @@ -27,6 +25,7 @@ Plug 'google/vim-jsonnet'
Plug 'guns/vim-clojure-highlight'
Plug 'guns/vim-clojure-static'
Plug 'henrik/vim-indexed-search'
Plug 'janko-m/vim-test'
Plug 'jergason/scala.vim'
Plug 'jgdavey/vim-turbux'
Plug 'hashivim/vim-terraform'
Expand All @@ -46,9 +45,6 @@ Plug 'mattn/emmet-vim'
Plug 'mileszs/ack.vim'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'pangloss/vim-javascript', { 'commit': 'ce0f529bbb938b42f757aeedbe8f5d95f095b51d' }
Plug 'pgr0ss/vimux-bazel-test'
Plug 'pgr0ss/vimux-ruby-test'
Plug 'pitluga/vimux-nose-test'
Plug 'rust-lang/rust.vim'
Plug 'scrooloose/nerdtree'
Plug 'tfnico/vim-gradle'
Expand Down

0 comments on commit 41b1e8d

Please sign in to comment.