mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Merge #4903
4903: Add highlighting support for doc comments r=matklad a=Nashenas88 The language server protocol includes a semantic modifier for documentation. This change exports that modifier for doc comments so users can choose to highlight them differently compared to regular comments. Example: <img width="375" alt="Screen Shot 2020-06-16 at 10 34 14 AM" src="https://user-images.githubusercontent.com/1673130/84788271-f6599580-afbc-11ea-96e5-7a0215da620b.png"> CC @woody77 Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
This commit is contained in:
commit
f7f627d342
5 changed files with 56 additions and 41 deletions
|
@ -489,7 +489,14 @@ fn highlight_element(
|
|||
}
|
||||
|
||||
// Simple token-based highlighting
|
||||
COMMENT => HighlightTag::Comment.into(),
|
||||
COMMENT => {
|
||||
let comment = element.into_token().and_then(ast::Comment::cast)?;
|
||||
let h = HighlightTag::Comment;
|
||||
match comment.kind().doc {
|
||||
Some(_) => h | HighlightModifier::Documentation,
|
||||
None => h.into(),
|
||||
}
|
||||
}
|
||||
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(),
|
||||
ATTR => HighlightTag::Attribute.into(),
|
||||
INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue