zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
38.09k stars 1.95k forks source link

Support dart doc comment highlight #11336

Open d1y opened 1 month ago

d1y commented 1 month ago

Check for existing issues

Describe the feature

Docs: https://dart.dev/effective-dart/documentation#doc-comments

It seems a markdown: https://dart.dev/effective-dart/documentation#markdown

Zed:

image

VScode:

image

If applicable, add mockups / screenshots to help present your vision of the feature

No response

d1y commented 1 month ago

Upstream It looks like there are two externals export:

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?

image

This will hand over all the text to Markdown

- xx
* xxx
/// - xxx <!-- prefix /// need remove? -->
/// [xxxx]
image

So. let's expose these two upstream?


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