Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight TODO, FIXME and XXX in comments #1164

Closed
bestouff opened this issue Nov 25, 2021 · 8 comments · Fixed by #1300
Closed

highlight TODO, FIXME and XXX in comments #1164

bestouff opened this issue Nov 25, 2021 · 8 comments · Fixed by #1300
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements

Comments

@bestouff
Copy link

(n)vim highlights these keywords in comments: TODO, FIXME and XXX. It's quite useful for spotting places to work on in source code.
image

@bestouff bestouff added the C-enhancement Category: Improvements label Nov 25, 2021
@pickfire pickfire added A-helix-term Area: Helix term improvements A-tree-sitter Area: Tree-sitter and removed A-helix-term Area: Helix term improvements labels Nov 25, 2021
@sudormrfbin
Copy link
Member

The PR to nvim-treesitter for supporting this same feature (nvim-treesitter/nvim-treesitter#893) and tree-sitter-comment which backs the PR and acts as an injection to provide highlights (https://github.com/stsewd/tree-sitter-comment).

@pickfire
Copy link
Contributor

I tried taking a look at this since I thought it was easy.

It works for some languages (scq, python) but didn't work for rust. But it only selects until the first word so you get a weird highlight.

Screenshot_20211126_080051

I believe it requires some changes in helix-core syntax to allow the use of injection as an overlay so that the original parts are still highlighted with comment as a fallback, currently it seemed to only highlight the first word as comment which is the matched regex for tree-sitter-comment.

pickfire added a commit to pickfire/helix that referenced this issue Nov 26, 2021
@bestouff
Copy link
Author

This is not quite the same. In vim the "grammar" is simpler; AFAIK it's just those 3 words, with no parenthesis or colon afterwards.

@pickfire
Copy link
Contributor

I think it's only useful in comments, what is your use case?

@bestouff
Copy link
Author

bestouff commented Nov 27, 2021

Same same (have a look at my screenshot). I was just saying in (n)vim it's only "FIXME" not "FIXME:" nor "FIXME(user):".

@sudormrfbin
Copy link
Member

Neovim uses the same tree-sitter grammar, so it's actually supported:

Screenshot_2021-11-28_12-14-13

@bestouff
Copy link
Author

TIL, thanks

archseer pushed a commit that referenced this issue Dec 19, 2021
* Add tree-sitter-comment

Fix #1164

* fix precedence in tree-sitter-comment highlights

connects #1170

* set injection-regex for comment language

* remove comment filetype

* fix comment injections for neovim-style injections tags

* add comment injections for elixir

* remove f.comment

* fix spacing in .gitmodules

* run 'cargo xtask docgen'

Co-authored-by: Ivan Tham <[email protected]>
@bestouff
Copy link
Author

Thanks all !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants