| File pack/apps/opt/uncov/autoload/uncov.vim added (mode: 100644) (index 0000000..8bc3fe8) | 
	|  | 1 |  | " Vim plugin for querying coverage information from uncov command-line tool. | 
	|  | 2 |  |  | 
	|  | 3 |  | " Maintainer: xaizek <xaizek@posteo.net> | 
	|  | 4 |  | " Last Change: 2020 April 24 | 
	|  | 5 |  | " License: Same terms as Vim itself (see `help license`) | 
	|  | 6 |  |  | 
	|  | 7 |  | """""""""""""""""""""""""""""""""""""""""""""""""""""""" | 
	|  | 8 |  |  | 
	|  | 9 |  | let s:initialized = 0 | 
	|  | 10 |  |  | 
	|  | 11 |  | function! uncov#ShowCoverage(reload, ...) abort | 
	|  | 12 |  | if !s:initialized | 
	|  | 13 |  | let s:initialized = 1 | 
	|  | 14 |  | call s:Initialize() | 
	|  | 15 |  | endif | 
	|  | 16 |  |  | 
	|  | 17 |  | let l:buildid = '@@' | 
	|  | 18 |  | if a:0 > 0 | 
	|  | 19 |  | if a:1 !~ '^@-\?\d\+\|@@$' | 
	|  | 20 |  | echohl ErrorMsg | echo 'Wrong argument:' a:1 | echohl None | 
	|  | 21 |  | return | 
	|  | 22 |  | endif | 
	|  | 23 |  | let l:buildid = a:1 | 
	|  | 24 |  | endif | 
	|  | 25 |  |  | 
	|  | 26 |  | if a:reload | 
	|  | 27 |  | let l:repo = b:uncovRepo | 
	|  | 28 |  | let l:relFilePath = b:uncovRelFilePath | 
	|  | 29 |  | else | 
	|  | 30 |  | let l:repo = fugitive#repo() | 
	|  | 31 |  | let l:relFilePath = FugitivePath(@%, '') | 
	|  | 32 |  | endif | 
	|  | 33 |  |  | 
	|  | 34 |  | call s:MakeBuffer(l:repo, l:relFilePath, l:buildid, a:reload) | 
	|  | 35 |  | endfunction | 
	|  | 36 |  |  | 
	|  | 37 |  | function! s:Initialize() | 
	|  | 38 |  | augroup Uncov | 
	|  | 39 |  | autocmd! ColorScheme * | 
	|  | 40 |  | \  highlight UncovCovered ctermbg=darkgreen guibg=darkgreen | 
	|  | 41 |  | \| highlight UncovMissed ctermbg=darkred guibg=darkred | 
	|  | 42 |  | augroup end | 
	|  | 43 |  | doautocmd Uncov ColorScheme | 
	|  | 44 |  |  | 
	|  | 45 |  | " mind that text is set to unbreakable space | 
	|  | 46 |  | sign define UncovCovered text=  texthl=UncovCovered | 
	|  | 47 |  | sign define UncovMissed text=  texthl=UncovMissed | 
	|  | 48 |  | endfunction | 
	|  | 49 |  |  | 
	|  | 50 |  | function! s:MakeBuffer(repo, relFilePath, buildid, reload) abort | 
	|  | 51 |  | let l:coverageInfo = systemlist('uncov '.a:repo.dir().' get '.a:buildid.' /' | 
	|  | 52 |  | \.shellescape(a:relFilePath)) | 
	|  | 53 |  | if v:shell_error != 0 | 
	|  | 54 |  | let l:errorMsg = 'uncov error: '.join(l:coverageInfo, '\n') | 
	|  | 55 |  | echohl ErrorMsg | echo l:errorMsg | echohl None | 
	|  | 56 |  | return | 
	|  | 57 |  | endif | 
	|  | 58 |  | let l:commit = l:coverageInfo[0] | 
	|  | 59 |  |  | 
	|  | 60 |  | let l:gitArgs = ['show', l:commit.':'.a:relFilePath] | 
	|  | 61 |  | let l:cmd = call(a:repo.git_command, l:gitArgs, a:repo) | 
	|  | 62 |  | let l:fileLines = systemlist(l:cmd) | 
	|  | 63 |  | if v:shell_error != 0 | 
	|  | 64 |  | let l:errorMsg = 'git error: '.join(l:fileLines, '\n') | 
	|  | 65 |  | echohl ErrorMsg | echo l:errorMsg | echohl None | 
	|  | 66 |  | return | 
	|  | 67 |  | endif | 
	|  | 68 |  |  | 
	|  | 69 |  | let l:cursPos = getcurpos() | 
	|  | 70 |  |  | 
	|  | 71 |  | if a:reload | 
	|  | 72 |  | enew | 
	|  | 73 |  | else | 
	|  | 74 |  | tabedit | 
	|  | 75 |  | endif | 
	|  | 76 |  |  | 
	|  | 77 |  | let b:uncovRepo = a:repo | 
	|  | 78 |  | let b:uncovRelFilePath = a:relFilePath | 
	|  | 79 |  |  | 
	|  | 80 |  | let l:coverage = l:coverageInfo[1:] | 
	|  | 81 |  | let [l:loclist, b:uncovCovered, b:uncoRelevant] = | 
	|  | 82 |  | \ s:ParseCoverage(l:coverage, l:fileLines) | 
	|  | 83 |  |  | 
	|  | 84 |  | " XXX: insert buildid here? | 
	|  | 85 |  | execute 'silent!' 'file' escape('uncov:'.a:relFilePath, ' \%') | 
	|  | 86 |  | call setline(1, l:fileLines) | 
	|  | 87 |  | setlocal buftype=nofile bufhidden=wipe noswapfile nomodified nomodifiable | 
	|  | 88 |  |  | 
	|  | 89 |  | execute 'doautocmd BufRead' a:relFilePath | 
	|  | 90 |  | execute 'doautocmd BufEnter' a:relFilePath | 
	|  | 91 |  |  | 
	|  | 92 |  | call cursor(l:cursPos[1:]) | 
	|  | 93 |  | call setloclist(0, l:loclist) | 
	|  | 94 |  | call s:FoldCovered(l:coverage) | 
	|  | 95 |  |  | 
	|  | 96 |  | " make sure line under the cursor is not folded | 
	|  | 97 |  | silent! normal! zO | 
	|  | 98 |  |  | 
	|  | 99 |  | command -buffer UncovInfo call s:PrintCoverageInfo() | 
	|  | 100 |  | command -buffer -nargs=? Uncov call uncov#ShowCoverage(1, <f-args>) | 
	|  | 101 |  |  | 
	|  | 102 |  | UncovInfo | 
	|  | 103 |  | endfunction | 
	|  | 104 |  |  | 
	|  | 105 |  | function! s:ParseCoverage(coverage, fileLines) abort | 
	|  | 106 |  | let l:loclist = [] | 
	|  | 107 |  | let l:bufnr = bufnr('%') | 
	|  | 108 |  |  | 
	|  | 109 |  | let l:lineNo = 1 | 
	|  | 110 |  | let l:relevant = 0 | 
	|  | 111 |  | let l:covered = 0 | 
	|  | 112 |  | for l:hits in a:coverage | 
	|  | 113 |  | let l:hits = str2nr(l:hits) | 
	|  | 114 |  | if l:hits != -1 | 
	|  | 115 |  | let l:group = (l:hits == 0) ? 'UncovMissed' : 'UncovCovered' | 
	|  | 116 |  | execute 'sign place' l:lineNo | 
	|  | 117 |  | \ 'line='.l:lineNo | 
	|  | 118 |  | \ 'name='.l:group | 
	|  | 119 |  | \ 'buffer='.l:bufnr | 
	|  | 120 |  | if l:hits == 0 | 
	|  | 121 |  | let l:loclist += [{ | 
	|  | 122 |  | \ 'bufnr': l:bufnr, | 
	|  | 123 |  | \ 'lnum': l:lineNo, | 
	|  | 124 |  | \ 'text': '(not covered) '.a:fileLines[l:lineNo - 1] }] | 
	|  | 125 |  | else | 
	|  | 126 |  | let l:covered += 1 | 
	|  | 127 |  | endif | 
	|  | 128 |  | let l:relevant += 1 | 
	|  | 129 |  | endif | 
	|  | 130 |  |  | 
	|  | 131 |  | let l:lineNo += 1 | 
	|  | 132 |  | endfor | 
	|  | 133 |  |  | 
	|  | 134 |  | return [l:loclist, l:covered, l:relevant] | 
	|  | 135 |  | endfunction | 
	|  | 136 |  |  | 
	|  | 137 |  | function! s:FoldCovered(coverage) abort | 
	|  | 138 |  | let l:nLines = line('$') | 
	|  | 139 |  |  | 
	|  | 140 |  | let l:lineNo = 1 | 
	|  | 141 |  | let l:toFold = 0 | 
	|  | 142 |  | for l:hits in a:coverage | 
	|  | 143 |  | if str2nr(l:hits) == 0 | 
	|  | 144 |  | if l:toFold > 3 | 
	|  | 145 |  | let l:startContext = (l:toFold == l:lineNo - 1 ? 0 : 1) | 
	|  | 146 |  | execute (l:lineNo - (l:toFold - l:startContext)).',' | 
	|  | 147 |  | \.(l:lineNo - 1 - 1) | 
	|  | 148 |  | \.'fold' | 
	|  | 149 |  | endif | 
	|  | 150 |  |  | 
	|  | 151 |  | let l:toFold = 0 | 
	|  | 152 |  | else | 
	|  | 153 |  | let l:toFold += 1 | 
	|  | 154 |  | endif | 
	|  | 155 |  |  | 
	|  | 156 |  | let l:lineNo += 1 | 
	|  | 157 |  |  | 
	|  | 158 |  | " handle case when coverage information contains more lines than the | 
	|  | 159 |  | " file gracefully by adjusting line number and number of lines to fold | 
	|  | 160 |  | " to do not go past the end of the buffer | 
	|  | 161 |  | if l:lineNo > l:nLines + 1 | 
	|  | 162 |  | let l:lineNo -= 1 | 
	|  | 163 |  | if l:toFold > 0 | 
	|  | 164 |  | let l:toFold -= 1 | 
	|  | 165 |  | endif | 
	|  | 166 |  | endif | 
	|  | 167 |  | endfor | 
	|  | 168 |  |  | 
	|  | 169 |  | if l:toFold > 3 | 
	|  | 170 |  | let l:startContext = (l:toFold == len(a:coverage) ? 0 : 1) | 
	|  | 171 |  | execute (l:lineNo - (l:toFold - l:startContext)).',' | 
	|  | 172 |  | \.(l:lineNo - 1) | 
	|  | 173 |  | \.'fold' | 
	|  | 174 |  | endif | 
	|  | 175 |  | endfunction | 
	|  | 176 |  |  | 
	|  | 177 |  | function! s:PrintCoverageInfo() abort | 
	|  | 178 |  | " redraw is to avoid message disappearing (see `:help :echo-redraw`) | 
	|  | 179 |  | redraw | 
	|  | 180 |  |  | 
	|  | 181 |  | let l:covered = b:uncovCovered | 
	|  | 182 |  | let l:relevant = b:uncoRelevant | 
	|  | 183 |  |  | 
	|  | 184 |  | let l:coverage = l:relevant != 0 ? 1.0*l:covered/l:relevant : 1.0 | 
	|  | 185 |  | echomsg printf('Coverage: %3.2f%% (%d/%d)', 100.0*l:coverage, | 
	|  | 186 |  | \ l:covered, l:relevant) | 
	|  | 187 |  | endfunction | 
| File pack/apps/opt/uncov/doc/uncov.txt added (mode: 100644) (index 0000000..b21f7c0) | 
	|  | 1 |  | *uncov.txt*               For Vim version 7.4         Last change: 2017 May 09 | 
	|  | 2 |  |  | 
	|  | 3 |  |  | 
	|  | 4 |  | uncov plugin documentation | 
	|  | 5 |  |  | 
	|  | 6 |  |  | 
	|  | 7 |  | uncov plugin                                    *uncov* | 
	|  | 8 |  |  | 
	|  | 9 |  | 1. Prerequisites................................|uncov-prerequisites| | 
	|  | 10 |  | 2. Description..................................|uncov-description| | 
	|  | 11 |  | 3. Usage........................................|uncov-usage| | 
	|  | 12 |  |  | 
	|  | 13 |  | Author:  xaizek <xaizek@posteo.net> | 
	|  | 14 |  | License: Same terms as Vim itself (see |license|) | 
	|  | 15 |  |  | 
	|  | 16 |  | ============================================================================== | 
	|  | 17 |  | 1. Prerequisites                                *uncov-prerequisites* | 
	|  | 18 |  |  | 
	|  | 19 |  | Vim-fugitive plugin by Tim Pope: | 
	|  | 20 |  |  | 
	|  | 21 |  | https://github.com/tpope/vim-fugitive.git | 
	|  | 22 |  |  | 
	|  | 23 |  | This dependency can be removed in future versions. | 
	|  | 24 |  |  | 
	|  | 25 |  | ============================================================================== | 
	|  | 26 |  | 2. Description                                  *uncov-description* | 
	|  | 27 |  |  | 
	|  | 28 |  | This plugin provides integration with uncov command-line tool.  It helps to | 
	|  | 29 |  | view latest coverage information about currently opened file easily. | 
	|  | 30 |  |  | 
	|  | 31 |  | The plugin opens a separate tab page with contents current file had at the | 
	|  | 32 |  | moment of coverage collection.  The buffer in that tab: | 
	|  | 33 |  |  | 
	|  | 34 |  | * has sign column set to show covered and missed lines; | 
	|  | 35 |  | * has location list filled with list of uncovered lines; | 
	|  | 36 |  | * has folds set on ranges that are covered; | 
	|  | 37 |  | * has cursor set near its position in the original buffer; | 
	|  | 38 |  | * displays file coverage information on command-line (once). | 
	|  | 39 |  |  | 
	|  | 40 |  | ============================================================================== | 
	|  | 41 |  | 3. Usage                                        *uncov-usage* | 
	|  | 42 |  |  | 
	|  | 43 |  | :Uncov [buildid]                                *uncov-:Uncov* *:Uncov* | 
	|  | 44 |  |  | 
	|  | 45 |  | In non-uncov buffer, loads coverage of current file in a buffer of a new tab | 
	|  | 46 |  | page.  When already in uncov buffer, reloads coverage of a file in current | 
	|  | 47 |  | buffer, but possibly from a different build. | 
	|  | 48 |  |  | 
	|  | 49 |  | Without argument latest build (@@) is used. | 
	|  | 50 |  |  | 
	|  | 51 |  | :UncovInfo                                      *uncov-:UncovInfo* *:UncovInfo* | 
	|  | 52 |  |  | 
	|  | 53 |  | Loads coverage of current file in a buffer of a new tab page. | 
	|  | 54 |  | The command is local to buffers created by this plugin. | 
	|  | 55 |  |  | 
	|  | 56 |  | ------------------------------------------------------------------------------ | 
	|  | 57 |  | vim:tw=78:ts=8:ft=help:norl: |