problem with running spec in vim

I have been using Vim for almost a week now.

I am using the dotvim configuration by Astrails.

All in all, the configuration is awesome and I completely love it, it’s the longest time period I have ever used Vim. Considering that the second place is about 5 minutes, that’s super impressive.

I only have one problem with it.

I took the spec running functions from Gary Bernhardt dotfiles, I just remapped the keys differently.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map ' :call RunTestFile()
</span>map ; :call RunNearestTest()
</span>
function! RunTestFile(...)
    if a:0
        let command_suffix = a:1
    else
        let command_suffix = ""
    endif

    " Run the tests for the previously-marked file.
    let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
    if in_test_file
        call SetTestFile()
    elseif !exists("t:grb_test_file")
        return
    end
    call RunTests(t:grb_test_file . command_suffix)
endfunction

function! RunNearestTest()
    let spec_line_number = line('.')
    call RunTestFile(":" . spec_line_number . " -b")
endfunction

function! SetTestFile()
    " Set the spec file that tests will be run for.
    let t:grb_test_file=@%
endfunction

function! RunTests(filename)
    " Write the file and run tests for the given filename
    :w
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
    if match(a:filename, '\.feature$') != -1
        exec ":!script/features " . a:filename
    else
        if filereadable("script/test")
            exec ":!script/test " . a:filename
        elseif filereadable("Gemfile")
            exec ":!bundle exec rspec --color " . a:filename
        else
            exec ":!rspec --color " . a:filename
        end
    end
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</code></pre></td></tr></table></div></figure>


As you can see, I mapped ,; to run line specs, and ,' to run the entire spec file.

The problem is, that the terminal exists immediately after the result, does not wait for me to hit Enter or anything.

You can see the problem demo in this YouTube Video

I asked this question on StackOverflow here

Someone suggested it might be a trailing character, but I checked and there’s nothing like that.

The same person suggested to map just ls like so:

1
nmap ls :!ls</span></code></pre></td></tr></table></div></figure>


But this command does not exit.

Another thing I tried is this In a vim session I mapped a key like this

1
map ~ :!rspec %</span></code></pre></td></tr></table></div></figure>


When I used it, the terminal did not exit as well.

Vim Experts, what am I missing here?

Running specs all the time is something crucial to my workflow, I don’t want to hide vim very time, it breaks my flow.

Any help appreciated.

My entire vim configuration is here: link

Developer