Skip to content

Commit 4435424

Browse files
committed
Open strategy
1 parent e2f7bc1 commit 4435424

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,17 @@ wildignore flag directly in your `.vimrc` configuration file.
5353
:set wildignore+=**/vendor/**
5454
```
5555

56+
## Open Strategy
57+
58+
The open strategy comes in help when you want to open the related test
59+
in a new window, split, tab etc..
60+
61+
```viml
62+
let g:relatedtest_open_strategy = 'vsp'
63+
```
64+
65+
You can use any vim command as open strategy, the most common are:
66+
- vsp (open in a vertical split)
67+
- sp (open in an horizontal split)
68+
- tabnew (open in a tab)
69+
- e (open in the current window)

autoload/relatedtest.vim

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ function! s:GetInputResponse(prompt, inputChoices)
2222
endfunction
2323

2424
function! relatedtest#handleTT()
25-
let a:bufname = bufname('%')
26-
if RelatedTestIsTest(a:bufname) > 0
27-
let relatedtest_filename = RelatedTestGetFileName(a:bufname)
25+
let bufname = bufname('%')
26+
if RelatedTestIsTest(bufname) > 0
27+
let relatedtest_filename = RelatedTestGetFileName(bufname)
2828
else
29-
let relatedtest_filename = RelatedTestGetTestFileName(a:bufname)
29+
let relatedtest_filename = RelatedTestGetTestFileName(bufname)
3030
endif
31-
31+
let open_strategy = ":" . g:relatedtest_open_strategy . " "
3232
if filereadable(relatedtest_filename)
33-
exec ":e " . relatedtest_filename
33+
exec open_strategy . relatedtest_filename
3434
else
3535
if s:GetInputResponse("Test file '" . relatedtest_filename . "' doesn't exists. Create a new test file (y/n)?", ['y', 'n']) == 'y'
36-
exec ":e " . relatedtest_filename
36+
exec open_strategy . relatedtest_filename
3737
endif
3838
endif
3939
endfunction

doc/vim-relatedtest.txt

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Section 3: Mappings *RelatedTestMappings*
4242

4343
You can override the default mapping in your `.vimrc` configuration file >
4444
let g:relatedtest_open_command = '<C-t>'
45+
let g:relatedtest_open_strategy = 'vsp'
4546
<
4647

4748
==============================================================================

plugin/relatedtest.vim

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ if !exists('g:relatedtest_open_command')
1616
let g:relatedtest_open_command = 'tt'
1717
endif
1818

19+
if !exists('g:relatedtest_open_strategy')
20+
let g:relatedtest_open_strategy = 'e'
21+
endif
22+
1923
exec "nmap <silent> " . g:relatedtest_open_command . " :call relatedtest#handleTT()<CR>"

0 commit comments

Comments
 (0)