GithubHelp home page GithubHelp logo

thatch / coverage-highlight.vim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mgedmin/coverage-highlight.vim

0.0 0.0 0.0 635 KB

Vim plugin to highlight Python source code lines that lack test coverage

License: MIT License

Python 79.00% Vim Script 21.00%

coverage-highlight.vim's Introduction

coverage-highlight.vim

Vim plugin to highlight source code lines that lack test coverage.

Screenshot

Currently supports only these Python coverage tracking tools:

Usage

  1. Generate some coverage data (a .coverage file) by running your tests with coverage run (or by using the appropriate test runner plugin).
  2. Open a source file in vim
  3. :HighlightCoverage

Commands

:HighlightCoverage

Highlight untested source code lines.

Tries to find the corresponding coverage report by looking for files named .coverage here (or in parent directories).

Also looks for looking for files named coverage/<module>.report to support trace.py reports, which are produced by zope.testrunner if you specify --coverage=coverage.

:HighlightCoverage NN-NN,NN-NN,NN,...

Highlight the specified source code lines and ranges.

The format matches that produced by coverage report -m, so you can copy & paste the ranges to the Vim command line from a web page, instead of having to hunt down and download .coverage files.

:HighlightCoverage <filename>.report

Highlight untested source code lines from a trace.py report.

Report files are just source code files indented with the number of executions or '>>>>>>' for uncovered lines prepended at the left margin.

:HighlightCoverageForAll

Highlight untested source lines for all files mentioned in the coverage report.

Only works with coverage.py reports.

Skips files not currently loaded into buffers, due to a limitation of Vim.

:HighlightCoverageOff

Turns off coverage highlighting

:ToggleCoverage

Toggles coverage highlighting on and off

:NextUncovered

Jump to the next uncovered range of source lines

:PrevUncovered

Jump to the previous uncovered range of source lines

Settings

g:coverage_script

Default: "" (which means autodetect)

Name of the script that can produce reports. Example:

let g:coverage_script = 'python3 -m coverage'

By default it looks for coverage in your PATH, and if not found, it looks for bin/coverage relative to the current working directory.

g:coverage_sign

Default: "↣" (">>" on non-UTF-8 setups)

g:coverage_sign_branch

Default: "↦" ("~>" on non-UTF-8 setups)

g:coverage_sign_branch_target

Default: "⇥" (">~" on non-UTF-8 setups)

Signs used in sign_column (empty string allowed). Example:

let g:coverage_sign = '#'
let g:coverage_sign_branch_target = ''

Highlight groups

If you want to change the highlighting, add this to your .vimrc:

highlight NoCoverage ctermbg=... guibg=...
highlight NoBranchCoverage ctermbg=... guibg=...
highlight NoBranchCoverageTarget ctermbg=... guibg=...

with the colors you want. See vim's :help cterm-colors and :help gui-colors for the color values to use.

Mappings

You may want to add this to your .vimrc:

noremap [C :<C-U>PrevUncovered<CR>
noremap ]C :<C-U>NextUncovered<CR>

Status line

Add %{coverage_highlight#get_current()} to your 'statusline' to show the coverage percentage for the current file, updated when you run :HighlightCoverage.

Add %{coverage_highlight#get_total()} to your 'statusline' to show the coverage percentage for the current project, updated when you run :HighlightCoverageForAll.

You can pass a format string to either function to customize how the coverage is to be displayed. The default is "%s%%".

Example :

set statusline=%<%f\ %h%m%r\ %1*%{coverage_highlight#get_current()}%*%=%-14.(%l,%c%V%)\ %P

Requirements

Vim 8.0.0251 or newer with Python or Python3 support.

Copyright

coverage-highlight.vim was written by Marius Gedminas <[email protected]> and contributors. Licence: MIT.

coverage-highlight.vim's People

Contributors

mgedmin avatar jwodder avatar daliusd avatar sscherfke avatar tevansuk avatar ljmc-github avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.