Skip to content

anphir/zed-comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zed Comment

An extension for the Zed editor to enable highlighting of alerts and URIs in comments.

Overview

The extension implements a generic “comment language” which may be injected in other Zed language extensions to enable highlighting of comments annotated with TODO:, FIXME:, …​ . This works similar to highlighting e.g. JavaScript embedded in an HTML document.

It uses the tree-sitter-comment grammar, specific Tree-sitter highlighting queries and a set of matching highlight style definitions.

Current State

Note
Pending pull request #2865 at Zed Extensions.
screenshot line comment
Figure 1. Zed highlighting line comments.
screenshot block comment
Figure 2. Zed highlighting block comments.

While tree-sitter-comment supports a wide range of comment tag names, in its current experimental state this extension highlights only a selected few of them, partitioned into four groups.

Note group

INFO, NOTE

Todo group

TEST, TODO, WIP

Warning group

WARN, WARNING

Error group

BUG, ERROR, FIXME

Each group uses three distinct styles to highlight comment tag name, comment tag user and comment text. The surrounding brackets and the trailing colon use the current theme’s punctuation styles, URIs the theme’s URI link style.

Unless theme creators decide to include them, the custom styles for comment tag name, user and text need to be added to Zed’s settings.json, otherwise the default comment style will be applied. While the styles use fixed names (e.g. comment.note.name), color etc. can be customized.

The guide for trying out a development extension installation contains an example of the required settings.

Usage

This “comment language extension” is only one piece of the puzzle. Each Zed extension for a language featuring comments to be highlighted needs to be adapted to use the comment extension. This is done by defining a “language injection”. Zed’s online documentaton contains a short description of this mechanism.

Just installing the “comment language extension” will not cause any comments to be highlighted. At least with version 0.190.5 of Zed there seems to be no way to trigger comment highlighting from “outside” a language extension. These extensions need to be changed and updated versions installed. For many languages this change should be small.

Zed users who are willing to do a bit of tinkering and install development extensions may already give comment highlighting a try. The procedure is described in the guide for trying out a development extension installation.

About

Zed editor extension enabling comment highlighting

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages