Skip to content

Commit 4fc43da

Browse files
committed
Add initial omnisharptest syntax file
1 parent 989a4ad commit 4fc43da

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

autoload/OmniSharp/testrunner.vim

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

4+
let s:state2char = {
5+
\ 'Not run': '|',
6+
\ 'Running': '-',
7+
\ 'Passed': '*',
8+
\ 'Failed': '#'
9+
\}
10+
411
function! OmniSharp#testrunner#Open() abort
512
if !OmniSharp#actions#test#Validate() | return | endif
613
call s:Open()
@@ -30,7 +37,7 @@ function s:Open() abort
3037
botright new
3138
endif
3239

33-
silent setlocal noswapfile signcolumn=no
40+
silent setlocal noswapfile signcolumn=no conceallevel=3 concealcursor=nv
3441
set bufhidden=hide
3542
let &filetype = ft
3643
execute 'file' title
@@ -51,8 +58,9 @@ function! s:Paint() abort
5158
if !has_key(job, 'tests') | continue | endif
5259
for testfile in keys(job.tests)
5360
put =' ' . fnamemodify(testfile, ':.')
54-
for test in job.tests[testfile]
55-
put =' ' . test.name
61+
for name in keys(job.tests[testfile])
62+
let test = job.tests[testfile][name]
63+
put =printf('%s %s', s:state2char[test.state], name)
5664
endfor
5765
endfor
5866
put =''
@@ -68,7 +76,14 @@ function! OmniSharp#testrunner#SetTests(bufferTests) abort
6876
let job = OmniSharp#GetHost(buffer.bufnr).job
6977
let job.tests = get(job, 'tests', {})
7078
let filename = fnamemodify(bufname(buffer.bufnr), ':p')
71-
let job.tests[filename] = buffer.tests
79+
let existing = get(job.tests, filename, {})
80+
let job.tests[filename] = existing
81+
for test in buffer.tests
82+
let extest = get(existing, test.name, { 'state': 'Not run' })
83+
let existing[test.name] = extest
84+
let extest.framework = test.framework
85+
let extest.lnum = test.nameRange.Start.Line
86+
endfor
7287
endfor
7388
call s:Open()
7489
call win_gotoid(winid)

syntax/omnisharptest.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
if exists('b:current_syntax')
2+
finish
3+
endif
4+
5+
let s:save_cpo = &cpoptions
6+
set cpoptions&vim
7+
8+
syn match ostStateNotRun "^|.*" contains=ostStateChar
9+
syn match ostStateRunning "^-.*" contains=ostStateChar
10+
syn match ostStatePassed "^\*.*" contains=ostStateChar
11+
syn match ostStateFailed "^#.*" contains=ostStateChar
12+
syn match ostStateChar "^[|\*#-]" conceal contained
13+
14+
hi def link ostStateNotRun Comment
15+
hi def link ostStateRunning Identifier
16+
hi def link ostStatePassed Title
17+
hi def link ostStateFailed WarningMsg
18+
19+
let b:current_syntax = 'omnisharptest'
20+
21+
let &cpoptions = s:save_cpo
22+
unlet s:save_cpo
23+
24+
" vim:et:sw=2:sts=2

0 commit comments

Comments
 (0)