stsewd / tree-sitter-comment

Tree-sitter grammar for comment tags like TODO, FIXME(user).
https://stsewd.dev/tree-sitter-comment/
MIT License
134 stars 9 forks source link

Make trailing colon optional for all markers #13

Closed erikw closed 2 years ago

erikw commented 2 years ago

Hey, thanks for providing this parser!

There are some different styles out there for markers in common, two being e.g. TODO and TODO:. I noticed that this parser supports, which is great (I prefer the first to save one character).

However it seems like for the marker for notes, only NOTE: is detected but not NOTE, which I frequently use.

Would it be possible to make the trailing colon optional for all markers?

stsewd commented 2 years ago

@erikw hi! you can already do this with a query, for example:

https://github.com/nvim-treesitter/nvim-treesitter/blob/9b13872f19aa97916ba0ae92bac6fb9e2c1dd06d/queries/comment/highlights.scm#L13-L14

The text node exposes all words that aren't tags.

erikw commented 2 years ago

@stsewd thanks for your support!

The following worked for me.

$ mkdir -p $XDG_CONFIG_HOME/nvim/queries/comment
$ touch $XDG_CONFIG_HOME/nvim/queries/comment/highlights.scm

and set highlights.scm to the contents:

("text" @text.warning
 (#any-of? @text.warning "NOTE" ))

What do you think about adding this to tree-sitter-comment directly? To make it consistent with that how TODO markers are recognized [also without trailing colon]?

stsewd commented 2 years ago

What do you think about adding this to tree-sitter-comment directly? To make it consistent with that how TODO markers are recognized [also without trailing colon]?

I think it makes sense to have it upstream, feel free to open a PR and see what the others think.