
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Grammar for code tags like TODO:, FIXME(user): for the tree-sitter parsing library
Tree-sitter grammar for comment tags like TODO:
, FIXME(user):
, etc.
Useful to be embedded inside comments.
Check the playground at https://stsewd.dev/tree-sitter-comment/.
Since comment tags aren't a programming language or have a standard, I have chosen to follow popular conventions for the syntax.
-
, _
(they can't start or end with these characters)()
:
and a whitespaceIf you think there are other popular conventions this syntax doesn't cover, feel free to open a issue.
TODO: something needs to be done
TODO(stsewd): something needs to be done by @stsewd
XXX: fix something else.
XXX: extra white spaces.
(NOTE: this works too).
NOTE-BUG (stsewd): tags can be separated by `-`
NOTE_BUG: or by `_`.
This will be recognized as a URI
https://github.com/stsewd/
:
, like TODO
?This grammar doesn't provide a specific token for it, but you can match it with this query:
("text" @todo
(#eq? @todo "TODO"))
#10
or !10
?This grammar doesn't provide a specific token for it, but you can match it with this query:
("text" @issue
(#match? @issue "^#[0-9]+$"))
;; NOTE: This matches `!10` and `! 10`.
("text" @symbol . "text" @issue
(#eq? @symbol "!")
(#match? @issue "^[0-9]+$"))
To avoid false positives, Neovim doesn't highlight all tags,
but a list of specific ones,
see the list at queries/comment/highlights.scm
.
If you want your tag highlighted, you can extend the query locally, see :h treesitter-query
.
Or if you think it's very common, you can suggest it upstream.
Tree-sitter is a LR parser for context-free grammars, that means it works great for grammars that don't require backtracking, or to keep a state for whitespaces (like indentation). For these reasons, parsing languages that need to keep a state or falling back to a general token, it requires some manual parsing in C.
FAQs
Grammar for code tags like TODO:, FIXME(user): for the tree-sitter parsing library
We found that tree-sitter-comment demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.