Skip to content

a vim plugin to display coverlet line coverage data in the current buffer

License

Notifications You must be signed in to change notification settings

nathanmentley/coverlet.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coverlet.vim

A simple vim plugin to display coverlet line coverage in vim.

Screen Shot

Installation

Requirements

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.

Plugin

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()

Global Variables

g:coverlet_file_name

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.

g:coverlet_foreground_color

Optional

Setting g:coverlet_foreground_color will allow you to override the font color for any highlighted text.

g:coverlet_uncovered_color

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.

g:coverlet_covered_color

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.

g:coverlet_branch_color

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.

Global Functions

CoverletToggle()

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.

CoverletRefresh()

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.

CoverletList()

Opens an immutable buffer with a list of uncovered lines and uncovered branches.

Example Setup


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.

Usage

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.

About

a vim plugin to display coverlet line coverage data in the current buffer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published