mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
feat: Add binding mode inlay hints
This commit is contained in:
parent
06448c5548
commit
6b696fced8
12 changed files with 201 additions and 41 deletions
|
@ -254,6 +254,8 @@ config_data! {
|
|||
/// The path structure for newly inserted paths to use.
|
||||
imports_prefix: ImportPrefixDef = "\"plain\"",
|
||||
|
||||
/// Whether to show inlay type hints for binding modes.
|
||||
inlayHints_bindingModeHints_enable: bool = "false",
|
||||
/// Whether to show inlay type hints for method chains.
|
||||
inlayHints_chainingHints_enable: bool = "true",
|
||||
/// Whether to show inlay type hints for return types of closures with blocks.
|
||||
|
@ -997,6 +999,7 @@ impl Config {
|
|||
ReborrowHintsDef::Never => ide::ReborrowHints::Never,
|
||||
ReborrowHintsDef::Mutable => ide::ReborrowHints::MutableOnly,
|
||||
},
|
||||
binding_mode_hints: self.data.inlayHints_bindingModeHints_enable,
|
||||
param_names_for_lifetime_elision_hints: self
|
||||
.data
|
||||
.inlayHints_lifetimeElisionHints_useParameterNames,
|
||||
|
|
|
@ -418,9 +418,9 @@ pub(crate) fn inlay_hint(
|
|||
lsp_types::InlayHint {
|
||||
position: match inlay_hint.kind {
|
||||
// before annotated thing
|
||||
InlayKind::ParameterHint | InlayKind::ImplicitReborrow => {
|
||||
position(line_index, inlay_hint.range.start())
|
||||
}
|
||||
InlayKind::ParameterHint
|
||||
| InlayKind::ImplicitReborrowHint
|
||||
| InlayKind::BindingModeHint => position(line_index, inlay_hint.range.start()),
|
||||
// after annotated thing
|
||||
InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::TypeHint
|
||||
|
@ -439,27 +439,30 @@ pub(crate) fn inlay_hint(
|
|||
InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
|
||||
Some(lsp_types::InlayHintKind::TYPE)
|
||||
}
|
||||
InlayKind::GenericParamListHint
|
||||
InlayKind::BindingModeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::ImplicitReborrow => None,
|
||||
| InlayKind::ImplicitReborrowHint => None,
|
||||
},
|
||||
tooltip: None,
|
||||
padding_left: Some(match inlay_hint.kind {
|
||||
InlayKind::TypeHint => !render_colons,
|
||||
InlayKind::ParameterHint | InlayKind::ClosureReturnTypeHint => false,
|
||||
InlayKind::ChainingHint => true,
|
||||
InlayKind::GenericParamListHint => false,
|
||||
InlayKind::LifetimeHint => false,
|
||||
InlayKind::ImplicitReborrow => false,
|
||||
InlayKind::BindingModeHint
|
||||
| InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::ImplicitReborrowHint
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::ParameterHint => false,
|
||||
}),
|
||||
padding_right: Some(match inlay_hint.kind {
|
||||
InlayKind::TypeHint | InlayKind::ChainingHint | InlayKind::ClosureReturnTypeHint => {
|
||||
false
|
||||
}
|
||||
InlayKind::ParameterHint => true,
|
||||
InlayKind::LifetimeHint => true,
|
||||
InlayKind::GenericParamListHint => false,
|
||||
InlayKind::ImplicitReborrow => false,
|
||||
InlayKind::ChainingHint
|
||||
| InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::ImplicitReborrowHint
|
||||
| InlayKind::TypeHint => false,
|
||||
InlayKind::BindingModeHint => inlay_hint.label != "&",
|
||||
InlayKind::ParameterHint | InlayKind::LifetimeHint => true,
|
||||
}),
|
||||
text_edits: None,
|
||||
data: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue