Moved spec opener to externalized plugin
This commit is contained in:
parent
10d947d5af
commit
8bc6bdc4be
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -305,3 +305,6 @@
|
||||
[submodule "zsh/zsh-syntax-highlighting"]
|
||||
path = zsh/zsh-syntax-highlighting
|
||||
url = git://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
[submodule "vim/bundle/skwp-vim-spec-finder"]
|
||||
path = vim/bundle/skwp-vim-spec-finder
|
||||
url = https://github.com/skwp/vim-spec-finder
|
||||
|
1
vim/bundle/skwp-vim-spec-finder
Submodule
1
vim/bundle/skwp-vim-spec-finder
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ccf250083cce96ed305af031bb5cb7cb98242330
|
@ -1,32 +0,0 @@
|
||||
" Find the related spec for any file you open. Requires
|
||||
" * Your specs live in spec/ or fast_spec/
|
||||
" * Your pwd (current dir) is the project root
|
||||
" * You use the same dir structure in your code and specs so that
|
||||
" code living at lib/foo/bar.rb has a spec at spec/lib/foo/bar.rb
|
||||
"
|
||||
" This method handles files in fast_spec unlike the :A and :AV functions
|
||||
" that ship with rails.vim
|
||||
function! FindSpec()
|
||||
let s:fullpath = expand("%:p")
|
||||
let s:filepath = expand("%:h")
|
||||
let s:fname = expand("%:t")
|
||||
|
||||
" Possible names for the spec/test for the file we're looking at
|
||||
let s:test_names = [substitute(s:fname, ".rb$", "_spec.rb", ""), substitute(s:fname, ".rb$", "_test.rb", "")]
|
||||
|
||||
" Possible paths
|
||||
let s:test_paths = ["spec", "fast_spec", "test"]
|
||||
for test_name in s:test_names
|
||||
for path in s:test_paths
|
||||
let s:filepath_without_app = substitute(s:filepath, "app/", "", "")
|
||||
let s:spec_path = path . "/" . s:filepath_without_app . "/" . test_name
|
||||
let s:full_spec_path = substitute(s:fullpath, s:filepath . "/" . s:fname, s:spec_path, "")
|
||||
if filereadable(s:full_spec_path)
|
||||
execute ":botright vsp " . s:full_spec_path
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
nnoremap <C-s> :call FindSpec()<CR>
|
Loading…
Reference in New Issue
Block a user