Skip to main content

tree-sitter-comment

CI

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/.

Syntax

Since comment tags aren't a programming language or have a standard, I have chosen to follow popular conventions for the syntax.

Comment tags

  • Comment tags can contain:
    • Upper case ascii letters
    • Numbers (can't start with one)
    • -, _ (they can't start or end with these characters)
  • Optionally can have an user linked to the tag inside parentheses ()
  • The name must be followed by : and a whitespace

URIs

  • http and https links are recognized

If you think there are other popular conventions this syntax doesn't cover, feel free to open a issue.

Examples

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/

FAQ

Can I match a tag that doesn't end in :, 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"))

Can I highlight references to issues, PRs, MRs, like #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]+$"))

I'm using Neovim and don't see all tags highlighted

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.

Why C?

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.

Projects using this grammar

Other grammars

Metadata

Release files for tree-sitter-comment 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-comment 0.3.0
File Size Uploaded
tree_sitter_comment-0.3.0.tar.gz 14.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-comment 0.3.0
File
tree_sitter_comment-0.3.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
tree_sitter_comment-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tree_sitter_comment-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 Details
tree_sitter_comment-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tree_sitter_comment-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 127.1 kB

Release files / tree_sitter_comment-0.3.0.tar.gz

Download URL tree_sitter_comment-0.3.0.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
89e4d2df4cfba95fae72c69f0c7571ebeb1b39e709b24151b4816e71a6079a07
BLAKE2b-256 checksum
How to use checksums
0540a2a2fb87508a8eb0b27b657a6584090fedd0337f174275627b6f2b7dfec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-win_arm64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-win_arm64.whl
Size 11.6 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
0e063c5e5afb99c0b25480e76450664373bbc06572ecad038b640bb32aa2c58f
BLAKE2b-256 checksum
How to use checksums
b4a657646ba7504990a467343d2af5eb105e699f6cceb73721dffdaeaf55f8ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-win_amd64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-win_amd64.whl
Size 12.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
89acd198c7602dcdb2df7dcb93afd13a24957ad52e8f7e8f592baf4ae7a8b80a
BLAKE2b-256 checksum
How to use checksums
e2ff74b995c85af195c7a427d8479326daa5be8d4934792dc5534ce7d439336f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 21.8 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e05e791513073bdf4205e46b94fc246ed4802ea116ce5fd82b9084c641ae5531
BLAKE2b-256 checksum
How to use checksums
c2a7621b9b19a799cc0276fb9ef6b0b1e17bce74a170e41fe382df8b931bd220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 23.0 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8aa53341821ccda6277762e652c5c779d7ecd4ea93d28f769142f8fef766eeae
BLAKE2b-256 checksum
How to use checksums
13fd58c6a7f1a8fc10625945e1fecfd9c180a415a5e79073058901e2c5312c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 22.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
5cc4f782432526bc2466caa38e39b20003f6c18018caf062d9b69b77a2a215dd
BLAKE2b-256 checksum
How to use checksums
1beb41258c6c7c5a0403784c290c3c1caf5bcd8789c6a35cbc00c5f7b9d3f4db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 10.5 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
335eadac6d4b341a62ddb460d1c9fa3ea5c914083fabea4c59d43d6024bcb465
BLAKE2b-256 checksum
How to use checksums
c162de9e6bfa2c0f4f8943d15b0b0cb638cb56a2e1932cdec5ff23d9424751c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tree_sitter_comment-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_comment-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl
Size 10.0 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
12b50167e7454fd5189d6f73cc483306b2a8ba165947255a0c1e828dca6448ea
BLAKE2b-256 checksum
How to use checksums
cf0ab021d8a7bd3fd1ecd008f9acc25d19329517091353892b0262ec95089c84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.3.0 This release

8 release files

0.2.0

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page