Highlight URI's in comments
yochem opened this issue · comments
Hi,
I don't know if this is the right place to ask, but I figured you might know the solution. I would like to highlight URI's in comments, so far, I've tried the following:
("text" @text.uri @nospell
(#lua-match? @text.uri "[a-z]*://[^ >,;]*"))
I verified the lua pattern:
> string.match('# TODO: test https://twitter.com test', "[a-z]*://[^ >,;]*")
https://twitter.com
What's weird, is that if I try to do for example only 'http', like so:
("text" @text.uri @nospell
(#lua-match? @text.uri "http"))
Could it be because :
is a node or something in the comment grammar?
Hi, so all text nodes are delimited by punctuation symbols (so we can detect things like (TODO: ...).TODO:..
To highlight the whole URL, you may try to match each individual part, like
("text" @_a @text.note . "text" @_b @text.note . "text" @_c @text.note (#match? @_a "^https?$") (#match? @_b "^:$") (#match? @_c "^/$"))
But adding support for URLs is something I wanted to add https://github.com/stsewd/tree-sitter-comment#todo, but wasn't sure if it would be okay to include.
Thanks! Will try it out. I think it would be very nice to include url's. I was also thinking about including something like a code node for text in backticks, but that might be too markdown-like.