Add the rust-analyzer.semanticHighlighting.comments.enable configuration value

This commit is contained in:
Bart Jacobs 2025-09-17 15:46:23 +02:00
parent 21614ed2d3
commit d106d41fbc
9 changed files with 157 additions and 19 deletions

View file

@ -35,6 +35,7 @@ use crate::{
};
pub(crate) use html::highlight_as_html;
pub(crate) use html::highlight_as_html_with_config;
#[derive(Debug, Clone, Copy)]
pub struct HlRange {
@ -47,6 +48,8 @@ pub struct HlRange {
pub struct HighlightConfig {
/// Whether to highlight strings
pub strings: bool,
/// Whether to highlight comments
pub comments: bool,
/// Whether to highlight punctuation
pub punctuation: bool,
/// Whether to specialize punctuation highlights
@ -588,6 +591,7 @@ fn descend_token(
fn filter_by_config(highlight: &mut Highlight, config: HighlightConfig) -> bool {
match &mut highlight.tag {
HlTag::StringLiteral if !config.strings => return false,
HlTag::Comment if !config.comments => return false,
// If punctuation is disabled, make the macro bang part of the macro call again.
tag @ HlTag::Punctuation(HlPunct::MacroBang) => {
if !config.macro_bang {