mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-29 05:14:18 +00:00
Make operator highlighting configurable, disable it by default
This commit is contained in:
parent
16315edaee
commit
afc8cfb4d1
2 changed files with 24 additions and 2 deletions
|
@ -400,7 +400,17 @@ config_data! {
|
||||||
///
|
///
|
||||||
/// When enabled, rust-analyzer will emit special token types for punctuation tokens instead
|
/// When enabled, rust-analyzer will emit special token types for punctuation tokens instead
|
||||||
/// of the generic `punctuation` token type.
|
/// of the generic `punctuation` token type.
|
||||||
semanticHighlighting_punctuation_specialize: bool = "false",
|
semanticHighlighting_punctuation_specialization_enable: bool = "false",
|
||||||
|
/// Use semantic tokens for operators.
|
||||||
|
///
|
||||||
|
/// When disabled, rust-analyzer will emit semantic tokens only for operator tokens when
|
||||||
|
/// they are tagged with modifiers.
|
||||||
|
semanticHighlighting_operator_enable: bool = "true",
|
||||||
|
/// Use specialized semantic tokens for operators.
|
||||||
|
///
|
||||||
|
/// When enabled, rust-analyzer will emit special token types for operator tokens instead
|
||||||
|
/// of the generic `operator` token type.
|
||||||
|
semanticHighlighting_operator_specialization_enable: bool = "false",
|
||||||
|
|
||||||
/// Show full signature of the callable. Only shows parameters if disabled.
|
/// Show full signature of the callable. Only shows parameters if disabled.
|
||||||
signatureInfo_detail: SignatureDetail = "\"full\"",
|
signatureInfo_detail: SignatureDetail = "\"full\"",
|
||||||
|
@ -538,6 +548,8 @@ pub struct HighlightingConfig {
|
||||||
pub strings: bool,
|
pub strings: bool,
|
||||||
pub punctuation: bool,
|
pub punctuation: bool,
|
||||||
pub specialize_punctuation: bool,
|
pub specialize_punctuation: bool,
|
||||||
|
pub specialize_operator: bool,
|
||||||
|
pub operator: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -1192,7 +1204,11 @@ impl Config {
|
||||||
HighlightingConfig {
|
HighlightingConfig {
|
||||||
strings: self.data.semanticHighlighting_strings_enable,
|
strings: self.data.semanticHighlighting_strings_enable,
|
||||||
punctuation: self.data.semanticHighlighting_punctuation_enable,
|
punctuation: self.data.semanticHighlighting_punctuation_enable,
|
||||||
specialize_punctuation: self.data.semanticHighlighting_punctuation_specialize,
|
specialize_punctuation: self
|
||||||
|
.data
|
||||||
|
.semanticHighlighting_punctuation_specialization_enable,
|
||||||
|
operator: self.data.semanticHighlighting_operator_enable,
|
||||||
|
specialize_operator: self.data.semanticHighlighting_operator_specialization_enable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -544,6 +544,12 @@ pub(crate) fn semantic_tokens(
|
||||||
tag @ HlTag::Punctuation(_) if !config.specialize_punctuation => {
|
tag @ HlTag::Punctuation(_) if !config.specialize_punctuation => {
|
||||||
*tag = HlTag::Punctuation(HlPunct::Other);
|
*tag = HlTag::Punctuation(HlPunct::Other);
|
||||||
}
|
}
|
||||||
|
HlTag::Operator(_) if !config.operator && highlight_range.highlight.mods.is_empty() => {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tag @ HlTag::Operator(_) if !config.specialize_operator => {
|
||||||
|
*tag = HlTag::Operator(HlOperator::Other);
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue