This project implements a Code Coverage Language Server that reads LCOV coverage reports and exposes the results through the Language Server Protocol.
Coverage information is surfaced using the
textDocument/documentColor
request, allowing editors to visually highlight covered and uncovered lines.
It also includes a Zed extension that integrates the language server with Zed.
This extension is available from Zed extension store and can be installed directly from the editor.
The extension may also be installed from source, by cloning
fargies/coverage-lsp repository and
selecting the zed-coverage-lsp directory from "Install Dev Extension" menu.
If not already found in path, the extension will download and install latest coverage-lsp server from GitHub's project releases.
To install your own version of coverage-lsp, simply use:
cargo install coverage-lspThe server can be configured through the following settings.
CSS color used to highlight covered lines.
- Accepts any valid CSS Color Level 4 value.
- Set to
nullto disable highlighting for covered lines. - Parsed using
csscolorparser. - Default:
rgba(0%,100%,0%,10%)
CSS color used to highlight uncovered lines.
- Accepts any valid CSS Color Level 4 value.
- Set to
nullto disable highlighting for uncovered lines. - Parsed using
csscolorparser. - Default:
rgba(100%,0%,0%,10%)
Path to the coverage file to load, either LCOV
or a Go cover profile (go test -coverprofile=coverage.out). The format is
detected from the file content.
- If not specified, the server searches the workspace and uses the first
*.info,coverage.outorcover.outfile it finds.
Interval used to check whether the coverage file has changed.
- Parsed using
humantime-serde. - Example values:
3s,20s,1m - Default:
3s
List of directories to ignore when crawling for a coverage file.
- Default:
[ node_modules, deps, incremental, bin, include, lib ]
ignore_hidden_dirs
Ignore directories starting with . when crawling for a coverage file.
- Default: true
Maximum directory depth during crawl.
- Default: 3
Workspace crawling interval used when looking for a file (then interval is used).
- Default: 15
{
"lsp": {
"coverage-lsp": {
"settings": {
"hit": null,
"miss": "#FFAA0020",
"interval": "20s",
"lcov_file": "./build/lcov.info"
}
}
}
}How coverage information is displayed in Zed depends on the LSP Document
Colors setting:
The language server provides the coverage colors, but the way those colors are rendered ultimately depends on your Zed theme. Here are some examples of the different visual styles you can achieve.
# remove downloaded releases
rm -rf ~/.local/share/zed/extensions/work/coverage-lsp/*
# or on MacOS
rm -rf /Users/fargie_s/Library/Application\ Support/Zed/extensions/work/coverage-lsp/*
# Clone and build this project
git clone https://github.com/fargies/coverage-lsp.git && cd coverage-lsp
cargo build
# Add `coverage-lsp` to your path
export PATH=$PATH:$(pwd)/target/debug
# Start `zeditor`
zeditor
# From the "Install Dev Extension" menu select `zed-coverage-lsp` directory
# Don't forget to "Rebuild" the extension and/or "Restart" the language-server to
# reflect changes