feat: Implement lifetime elision hints
This commit is contained in:
@@ -255,6 +255,8 @@ config_data! {
|
||||
inlayHints_chainingHints: bool = "true",
|
||||
/// Whether to show inlay type hints for return types of closures with blocks.
|
||||
inlayHints_closureReturnTypeHints: bool = "false",
|
||||
/// Whether to show inlay type hints for elided lifetimes in function signatures.
|
||||
inlayHints_lifetimeElisionHints: bool = "false",
|
||||
/// Whether to hide inlay hints for constructors.
|
||||
inlayHints_hideNamedConstructorHints: bool = "false",
|
||||
|
||||
@@ -855,6 +857,7 @@ impl Config {
|
||||
parameter_hints: self.data.inlayHints_parameterHints,
|
||||
chaining_hints: self.data.inlayHints_chainingHints,
|
||||
closure_return_type_hints: self.data.inlayHints_closureReturnTypeHints,
|
||||
lifetime_elision_hints: self.data.inlayHints_lifetimeElisionHints,
|
||||
hide_named_constructor_hints: self.data.inlayHints_hideNamedConstructorHints,
|
||||
max_length: self.data.inlayHints_maxLength,
|
||||
}
|
||||
|
||||
@@ -427,27 +427,34 @@ pub(crate) fn inlay_hint(
|
||||
}),
|
||||
position: match inlay_hint.kind {
|
||||
InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()),
|
||||
InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
|
||||
position(line_index, inlay_hint.range.end())
|
||||
}
|
||||
InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::TypeHint
|
||||
| InlayKind::ChainingHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::LifetimeHint => position(line_index, inlay_hint.range.end()),
|
||||
},
|
||||
kind: match inlay_hint.kind {
|
||||
InlayKind::ParameterHint => Some(lsp_ext::InlayHintKind::PARAMETER),
|
||||
InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
|
||||
Some(lsp_ext::InlayHintKind::TYPE)
|
||||
}
|
||||
InlayKind::GenericParamListHint | InlayKind::LifetimeHint => 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,
|
||||
}),
|
||||
padding_right: Some(match inlay_hint.kind {
|
||||
InlayKind::TypeHint | InlayKind::ChainingHint | InlayKind::ClosureReturnTypeHint => {
|
||||
false
|
||||
}
|
||||
InlayKind::ParameterHint => true,
|
||||
InlayKind::LifetimeHint => true,
|
||||
InlayKind::GenericParamListHint => false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user