Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View coverage.vim
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
"hi HitLine ctermbg=Cyan guibg=Cyan
"hi MissLine ctermbg=Magenta guibg=Magenta
hi HitSign ctermfg=Green cterm=bold gui=bold guifg=Green
hi MissSign ctermfg=Red cterm=bold gui=bold guifg=Red
 
sign define hit linehl=HitLine texthl=HitSign text=>>
sign define miss linehl=MissLine texthl=MissSign text=:(
 
"Generated by simplecov-vim
let s:coverage = {'flue.rb': [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],[]], 'flue/basefile.rb': [[1, 2, 4, 5, 6, 8, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34, 37, 38, 41, 42, 45, 46, 47, 51, 52, 53, 56, 57, 60, 61, 64, 66, 69, 71, 73, 74],[]], 'flue/benchmark.rb': [[1, 3, 4, 5, 6, 7, 8, 10, 11, 13],[]], 'flue/filter_register.rb': [[1, 2, 4, 5, 8, 9, 12, 13, 14, 15, 16, 21, 22, 23, 24, 27, 28, 29, 30, 31, 34, 35, 36, 37, 40],[]], 'flue/filters/code.rb': [[1, 2, 4, 5, 6, 7, 8, 9, 10, 12],[]], 'flue/filters/coffee_script.rb': [[1, 3, 4, 5, 6, 7, 8, 10, 12],[]], 'flue/filters/emoji.rb': [[1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 13],[]], 'flue/filters/erb.rb': [[1, 3, 4, 5, 6, 8, 9, 10, 11, 14, 17, 18, 19, 20],[]], 'flue/filters/markdown.rb': [[1, 3, 4, 5, 6, 7, 8, 10],[]], 'flue/filters/sass.rb': [[1, 3, 4, 5, 6, 7, 8, 10, 12, 13],[]], 'flue/filters/textile.rb': [[1, 3, 4, 5, 6],[]], 'flue/init.rb': [[1, 2, 3, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19],[]], 'flue/logger.rb': [[1, 3, 4, 5, 7, 8, 11, 12, 15, 16, 17, 20, 21],[]], 'flue/metadata.rb': [[1, 3, 4, 5, 7, 8, 11, 12],[13, 14, 15]], 'flue/middleware.rb': [[1, 3, 4, 5, 7, 8, 9, 10, 13, 14, 15, 16, 19, 20, 21, 24, 25, 26],[]], 'flue/partial_file.rb': [[1, 3, 4, 5, 6, 7, 9, 10, 13, 14, 17, 18],[]], 'flue/renderer.rb': [[1, 2, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 18, 19, 22, 23, 24, 28, 29, 30, 34, 35, 36, 37, 38, 41],[]], 'flue/runner.rb': [[1, 3, 4, 5, 7, 8, 13, 14, 15, 16, 22, 23],[9, 10, 17, 18, 19, 24, 25]], 'flue/server.rb': [[1, 2, 4, 5, 6, 8, 13],[9, 10, 14, 15, 16, 17]], 'flue/watcher.rb': [[1, 2, 3, 5, 6, 7, 10, 11, 14, 15, 16, 20, 21, 24, 25, 28, 29, 30, 31],[]], }
 
let s:generatedTime = 1382482226
 
function! BestCoverage(coverageForName)
let matchBadness = strlen(a:coverageForName)
for filename in keys(s:coverage)
let matchQuality = match(a:coverageForName, filename . "$")
if (matchQuality >= 0 && matchQuality < matchBadness)
let found = filename
endif
endfor
 
if exists("found")
return s:coverage[found]
else
echom "No coverage recorded for " . a:coverageForName
return [[],[]]
endif
endfunction
 
let s:signs = {}
let s:signIndex = 1
 
function! s:CoverageSigns(filename)
let [hits,misses] = BestCoverage(a:filename)
 
if (getftime(a:filename) > s:generatedTime)
echom "File is newer than coverage report which was generated at " . strftime("%c", s:generatedTime)
endif
 
if (! exists("s:signs['".a:filename."']"))
let s:signs[a:filename] = []
endif
 
for hit in hits
let id = s:signIndex
let s:signIndex += 1
let s:signs[a:filename] += [id]
exe ":sign place ". id ." line=".hit." name=hit file=" . a:filename
endfor
 
for miss in misses
let id = s:signIndex
let s:signIndex += 1
let s:signs[a:filename] += [id]
exe ":sign place ".id." line=".miss." name=miss file=" . a:filename
endfor
endfunction
 
function! s:ClearCoverageSigns(filename)
if(exists("s:signs['". a:filename."']"))
for signId in s:signs[a:filename]
exe ":sign unplace ".signId
endfor
let s:signs[a:filename] = []
endif
endfunction
 
let s:filename = expand("<sfile>")
function! s:AutocommandUncov(sourced)
if(a:sourced == s:filename)
call s:ClearCoverageSigns(expand("%:p"))
endif
endfunction
 
command! -nargs=0 Cov call s:CoverageSigns(expand("%:p"))
command! -nargs=0 Uncov call s:ClearCoverageSigns(expand("%:p"))
 
augroup SimpleCov
au!
exe "au SourcePre ".expand("<sfile>:t")." call s:AutocommandUncov(expand('<afile>:p'))"
augroup end
 
Cov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.