Devel::Cover::Report::Vim - Backend for displaying coverage data in Vim
cover -report vim
This module provides a reporting mechanism for displaying coverage data in Vim. It is designed to be called from the
By default, the output of this report is a file named
coverage.vim in the directory of the coverage database. To use it, run
and you should see signs in the left column indicating the coverage status of that line.
The signs are as follows:
P - Pod coverage S - Statement coverage R - Subroutine coverage B - Branch coverage C - Condition coverage
The last of the criteria, in the order given above, is the one which is displayed. Correctly covered criteria are shown in green. Incorrectly covered criteria are shown in red. Any incorrectly covered criterion will override a correctly covered criterion.
If the coverage for the file being displayed is out of date the a function called CoverageOld() is called and passed the name of the file. Similarly, for current coverage data file CoverageValid is called.
Signs may be overridden in a file named devel-cover.vim located somewhere underneath the ~/.vim directory.
For example, I use the solarized theme and keep the following commands in my local configuration file ~/.vim/local/devel-cover.vim:
let s:fg_cover = "#859900" let s:fg_error = "#dc322f" let s:bg_valid = "#073642" let s:bg_old = "#342a2a" let s:types = [ "pod", "subroutine", "statement", "branch", "condition", ] for s:type in s:types exe "highlight cov_" . s:type . " ctermbg=1 cterm=bold gui=NONE guifg=" . s:fg_cover exe "highlight cov_" . s:type . "_error ctermbg=1 cterm=bold gui=NONE guifg=" . s:fg_error endfor exe "highlight SignColumn ctermbg=0 guibg=" . s:bg_valid " highlight cov ctermbg=8 guibg=#002b36 " highlight err ctermbg=0 guibg=#073642 function! s:set_bg(bg) for s:type in s:types exe "highlight cov_" . s:type . " guibg=" . a:bg exe "highlight cov_" . s:type . "_error guibg=" . a:bg endfor exe "highlight SignColumn ctermbg=0 guibg=" . a:bg endfunction function! CoverageValid(filename) call s:set_bg(s:bg_valid) endfunction function! CoverageOld(filename) call s:set_bg(s:bg_old) endfunction
This configuration sets the background colour of the signs to a dark red when the coverage data is out of date.
coverage.vim adds two user commands: :Cov and :Uncov which can be used to toggle the state of coverage signs.
The idea and the vim template is shamelessly stolen from Simplecov-Vim. See https://github.com/nyarly/Simplecov-Vim
Devel::Cover Simplecov-Vim (https://github.com/nyarly/Simplecov-Vim)
Copyright 2012-2019, Paul Johnson (firstname.lastname@example.org)
This software is free. It is licensed under the same terms as Perl itself.
The latest version of this software should be available from my homepage: http://www.pjcj.net
The template is copied from Simplecov-Vim (https://github.com/nyarly/Simplecov-Vim) and is under the MIT Licence.
The MIT License
Copyright (c) 2011 Judson Lester
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.