-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[editors/code] add markdown syntax highlighting to doc comments #14866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[editors/code] add markdown syntax highlighting to doc comments #14866
Conversation
3d4f143 to
09f6247
Compare
|
Seems fine to add, though ideally we'd replaces this with semantic highlighting once we parse doc comments as markdown syntax trees |
|
☀️ Test successful - checks-actions |
|
So I just realized, but this does not work for me 🤔 Is there something specific one has to do in VSC to make injected grammars work? |
I'll have a look this week why it doesn't seem to work. I'm not at home for the foreseeable time and so need to find some time to setup rust-analyzer. It might have to do with the fact that I was testing this against the built-in Rust extension as well and it was quite fragile. Perhaps I made a mistake when making the PR or there is something different in production, I think it's the former. I'll try to get back later this week. |
Enables Markdown injection introduced in rust-lang#14866 but wasn't included in release due to it being ignored.
|
Also following up from the previous bug. I did not notice this behaviour when using the |
fix: exclude Markdown injection grammar from .vscodeignore. Enables Markdown injection introduced in #14866 but wasn't included in release due to the grammar file being ignored by `.vscodeignore`. I verified the fix by doing `vsce package` and installing it manually: <img width="779" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/bb3da211-a017-45bf-ba7b-4122335aa6e8"> <img width="780" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/aa0c4025-e72c-4b0c-9d40-44c33e7d45e6">


This is a continuation of microsoft/vscode#169956 and dustypomerleau/rust-syntax#37 (that repo is no longer maintained: dustypomerleau/rust-syntax#39 (comment)). The VS Code team seemed to prefer this being inside of an extension.
This adds Markdown highlighting to doc comment lines and blocks. Currently it is thus regarded both as a comment and as Markdown which leads to normally foreground text being in the colour of the comment and the rest highlighted like Markdown or its own embedded languages in code blocks.
Block comments are supported, but currently not when there is a


*at the start of the line:I'm not entirely sure if I can easily fix this, I'd need to find a way to make the content ignore the
*. Though I'm unsure if it's important as there are conventions against using block comments and using them without*does work. All of this TextMate grammar is so hard to find documentation on that honestly I'd just not want to support this considering the effort.Let me know what everyone thinks of this being in rust-analyzer. I've personally found it hard to write large amounts of Rust documentation due to the lack of Markdown syntax highlighting.
Also, thank you @adenine-dev as well for making this available in the interim and your enthousiasm. Wanted to get this PR out sooner, but life gets in the way.