zed
zed copied to clipboard
Support dart doc comment highlight
Check for existing issues
- [X] Completed
Describe the feature
Docs: https://dart.dev/effective-dart/documentation#doc-comments
It seems a markdown: https://dart.dev/effective-dart/documentation#markdown
Zed:
VScode:
If applicable, add mockups / screenshots to help present your vision of the feature
No response
Upstream It looks like there are two externals export:
- _block_comment
- _documentation_block_comment
https://github.com/UserNobody14/tree-sitter-dart/blob/ac0bb849ccd1a923963af47573b5e396736ff582/grammar.js#L2817-L2832
(((documentation_comment) @_documentation_block_comment
(#match? @_documentation_block_comment "^///\\s*\\S+")) @content
(#set! "language" "markdown"))
(((documentation_comment) @_block_comment
(#match? @_block_comment "^/\\*\\*\\s*\\S+\\s*\\*/")) @content
(#set! "language" "markdown"))
Work?
This will hand over all the text to Markdown
- xx
* xxx
/// - xxx <!-- prefix /// need remove? -->
/// [xxxx]
~~So. let's expose these two upstream?~~
- https://github.com/UserNobody14/tree-sitter-dart/blob/ac0bb849ccd1a923963af47573b5e396736ff582/grammar.js#L2822
- https://github.com/UserNobody14/tree-sitter-dart/blob/ac0bb849ccd1a923963af47573b5e396736ff582/grammar.js#L2830
~~I am really not familiar with tree sitter, and I would like to know if it is possible to use regex in injections.scm?@maxbrunsfeld~~
Like this:
; TODO: impl this?
(((documentation_comment) @_documentation_block_comment
(#match? @_documentation_block_comment "^///\\s*(\\S+)\\s*$")) #group(1) @content ; get match group in `\\S+`
(#set! "language" "markdown"))
Note: I know Neovim seems to have a #offset directive
https://github.com/tree-sitter/tree-sitter/issues/1944#issuecomment-1302459754