config/vimrc in zsh_dots-0.5.9 vs config/vimrc in zsh_dots-0.6.0
- old
+ new
@@ -20,10 +20,11 @@
Bundle 'tpope/vim-markdown'
Bundle 'skwp/vim-rspec'
Bundle 'tpope/vim-rails'
Bundle 'sunaku/vim-ruby-shoulda-context'
Bundle 'vim-scripts/nginx.vim'
+Bundle 'leshill/vim-json'
" Tools
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
@@ -268,23 +269,48 @@
endfunction
function! AlternateForCurrentFile()
let current_file = expand("%")
let new_file = current_file
let in_spec = match(current_file, '^spec/') != -1
- let going_to_spec_or_test = !in_spec
+ let in_test = match(current_file, '^test/') != -1
+ let using_test_unit = isdirectory('./test')
+
+ if using_test_unit
+ let going_to_spec = !in_spec
+ else
+ let going_to_spec = !in_test
+ endif
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1 || match(current_file, '\<helpers\>') != -1
+
if going_to_spec
if in_app
let new_file = substitute(new_file, '^app/', '', '')
end
+
let new_file = substitute(new_file, '\.rb$', '_spec.rb', '')
let new_file = 'spec/' . new_file
+
+ if using_test_unit
+ let new_file = substitute(new_file, '^spec/', 'test/', '')
+ let new_file = substitute(new_file, '_spec\.rb$', '_test.rb', '')
+ let is_unit = match(new_file, 'models') != -1
+ let is_func = match(new_file, 'controllers') != -1
+
+ if is_unit
+ let new_file = substitute(new_file, 'models', 'unit', '')
+ endif
+
+ if is_func
+ let new_file = substitute(new_file, 'controllers', 'functional', '')
+ endif
+ end
else
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
let new_file = substitute(new_file, '^spec/', '', '')
if in_app
let new_file = 'app/' . new_file
end
endif
+
return new_file
endfunction
nnoremap <leader>. :call OpenTestAlternate()<cr>