Open jhgg opened 2 years ago
rust-analyzer already provides highlighting in these code snippets in documentation
My VSCode fails to do full syntax-highlighting in doc tests: (rust-analyzer version: https://github.com/rust-lang/rust-analyzer/commit/7e95c14ea730c6b06f5760c8c92e69b9a6def828 2022-05-17 stable)
What editor are you using?
What editor are you using?
vscode however I have many semantic token colors set - since this isn't syntax as recognized by vscode (since it's in a comment) - the only thing that can color these are semantic tokens. If you hover over the code that isn't being colored and use "inspect token and scopes" you should see the semantic tokens. You can then assign them a color in your editor config.
If you hover over the code that isn't being colored and use "inspect token and scopes" you should see the semantic tokens
I am aware of the feature and have checked it already, it's not a color problem, the parser is wrong (whether it's a TextMate grammar or semantic). As you can see vec.len()
has the wrong type since it appears inside a function/macro call, while vec.push()
is fine
If you hover over the code that isn't being colored and use "inspect token and scopes" you should see the semantic tokens
I am aware of the feature and have checked it already, it's not a color problem, the parser is wrong (whether it's a TextMate grammar or semantic). As you can see
vec.len()
has the wrong type since it appears inside a function/macro call, whilevec.push()
is fine
Sorry, not really sure what you're asking then. If you want to know how I got colors in there it is via semantic token customization. The colors in my above example are also incorrect in the same fashion, no doubt because we probably are not descending into the macro to provide correct highlighting for tokens contained within.
This appears to be a duplicate of #4170. The write-up here is great though!
rust-analyzer already provides highlighting in these code snippets in documentation:
I think that it would be really awesome if we could also provide some IDE features in these snippets, namely hover, inlay hints, goto defintion and autocomplete/flyimports, rename, and maybe even diagnostics (perhaps diagnostics/inlay hints should only be active while your cursor is within the doc snippet to not be annoying outside of editing the snippet). It would make writing documentation examples much much easier and delightful too.