A simple vim plugin to display coverlet line coverage in vim.
This has only been tested with vim 8.1, but should work with pretty old version of vim.
This plugin requires that vim was compiled with python3 support.
coverlet.vim can be install using most vim plugin managers.
An example using:
https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'nathanmentley/coverlet.vim'
call plug#end()
Required - This value must be set for the plugin to function correctly.
Setting g:coverlet_file_name will tell coverlet.vim where to read the coverlet json file from. This setting should probably be setup per project.
Optional
Setting g:coverlet_foreground_color will allow you to override the font color for any highlighted text.
Optional
Setting g:coverlet_uncovered_color will allow you to override the background color for any text that is highlighted because it's uncovered by a unit test.
Optional
Setting g:coverlet_covered_color will allow you to override the background color for any text that is highlighted because it's covered by a unit test.
Optional
Setting g:coverlet_branch_color will allow you to override the background color for any text that is highlighted because it's a branch that isn't full covered by unit tests.
Chances are you won't want to always display which code is covered and which code isn't. Calling CoverletToggle() will enable and disable the code coverage display. It's recommended to bind that to a key command.
Right now this plugin wont detect changes to the json file and automatically update the coverage information. If you've updated the coverlet file. You should run CoverletRefresh() to update what vim is showing.
Opens an immutable buffer with a list of uncovered lines and uncovered branches.
call plug#begin('~/.vim/plugged')
Plug 'nathanmentley/coverlet.vim'
call plug#end()
let g:coverlet_file_name = "/Users/nathanmentley/Projects/coverlet_tests/coverage.json"
let g:coverlet_foreground_color = "233"
let g:coverlet_uncovered_color = "209"
let g:coverlet_covered_color = "50"
let g:coverlet_branch_color = "222"
nmap <S-t> :call CoverletToggle()<CR>
nmap <S-u> :call CoverletList()<CR>
nmap <S-y> :call CoverletRefresh()<CR>
With this configuration you can press Shift-T to enable or disable coverlet.vim, and you can press Shift-Y to refresh the data if it's displaying an old test run. Pressing Shift-U will display a buffer listing all the missing lines and non completely covered branches.
This plugin requires a coverlet json file to function. This plugin doesn't help call coverlet or generate that file. You'll need to either setup vim shortcuts to do that for your project or run coverlet outside of vim.