Last active
July 24, 2020 03:12
-
-
Save rerorero/016ba3c142d03c186481820f47db0b4a to your computer and use it in GitHub Desktop.
gotestfunc.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command GoUnitTest call s:go_unit_test() | |
function! s:go_unit_test() abort | |
let l:test = search('func \(Test\|Example\)', "bcnW") | |
if l:test == 0 | |
echo "no test found" | |
return | |
end | |
" run via termnial (neoterm) | |
let l:line = getline(l:test) | |
let l:name = split(split(l:line, " ")[1], "(")[0] | |
let l:filepath = expand('%:p:h') | |
let l:cmd = ':T go test -run ' . l:name . '$ ' . l:filepath . ' -v -count 1' | |
exe l:cmd | |
exe ':Ttoggle' | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment