Add option to skip trivial cases
This commit is contained in:
@@ -12,7 +12,8 @@ use std::{ffi::OsString, iter, path::PathBuf};
|
||||
use flycheck::FlycheckConfig;
|
||||
use ide::{
|
||||
AssistConfig, CompletionConfig, DiagnosticsConfig, ExprFillDefaultMode, HighlightRelatedConfig,
|
||||
HoverConfig, HoverDocFormat, InlayHintsConfig, JoinLinesConfig, Snippet, SnippetScope,
|
||||
HoverConfig, HoverDocFormat, InlayHintsConfig, JoinLinesConfig, LifetimeElisionHints, Snippet,
|
||||
SnippetScope,
|
||||
};
|
||||
use ide_db::{
|
||||
imports::insert_use::{ImportGranularity, InsertUseConfig, PrefixKind},
|
||||
@@ -248,19 +249,19 @@ config_data! {
|
||||
inlayHints_maxLength: Option<usize> = "25",
|
||||
/// Whether to show function parameter name inlay hints at the call
|
||||
/// site.
|
||||
inlayHints_parameterHints: bool = "true",
|
||||
inlayHints_parameterHints: bool = "true",
|
||||
/// Whether to show inlay type hints for variables.
|
||||
inlayHints_typeHints: bool = "true",
|
||||
inlayHints_typeHints: bool = "true",
|
||||
/// Whether to show inlay type hints for method chains.
|
||||
inlayHints_chainingHints: bool = "true",
|
||||
inlayHints_chainingHints: bool = "true",
|
||||
/// Whether to show inlay type hints for return types of closures with blocks.
|
||||
inlayHints_closureReturnTypeHints: bool = "false",
|
||||
inlayHints_closureReturnTypeHints: bool = "false",
|
||||
/// Whether to show inlay type hints for elided lifetimes in function signatures.
|
||||
inlayHints_lifetimeElisionHints: bool = "false",
|
||||
inlayHints_lifetimeElisionHints: LifetimeElisionDef = "\"never\"",
|
||||
/// Whether to show prefer using parameter names as the name for elided lifetime hints.
|
||||
inlayHints_paramNamesForLifetimeElisionHints: bool = "false",
|
||||
inlayHints_paramNamesForLifetimeElisionHints: bool = "false",
|
||||
/// Whether to hide inlay hints for constructors.
|
||||
inlayHints_hideNamedConstructorHints: bool = "false",
|
||||
inlayHints_hideNamedConstructorHints: bool = "false",
|
||||
|
||||
/// Join lines inserts else between consecutive ifs.
|
||||
joinLines_joinElseIf: bool = "true",
|
||||
@@ -859,7 +860,11 @@ 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,
|
||||
lifetime_elision_hints: match self.data.inlayHints_lifetimeElisionHints {
|
||||
LifetimeElisionDef::Always => LifetimeElisionHints::Always,
|
||||
LifetimeElisionDef::Never => LifetimeElisionHints::Never,
|
||||
LifetimeElisionDef::SkipTrivial => LifetimeElisionHints::SkipTrivial,
|
||||
},
|
||||
hide_named_constructor_hints: self.data.inlayHints_hideNamedConstructorHints,
|
||||
param_names_for_lifetime_elision_hints: self
|
||||
.data
|
||||
@@ -1133,6 +1138,16 @@ enum ImportGranularityDef {
|
||||
Module,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum LifetimeElisionDef {
|
||||
#[serde(alias = "true")]
|
||||
Always,
|
||||
#[serde(alias = "false")]
|
||||
Never,
|
||||
SkipTrivial,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum ImportPrefixDef {
|
||||
@@ -1385,7 +1400,16 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
_ => panic!("{}: {}", ty, default),
|
||||
"LifetimeElisionDef" => set! {
|
||||
"type": "string",
|
||||
"enum": ["always", "never", "skip_trivial"],
|
||||
"enumDescriptions": [
|
||||
"Always show lifetime elision hints.",
|
||||
"Never show lifetime elision hints.",
|
||||
"Always show lifetime elision hints but skip them for trivial single input to output mapping."
|
||||
],
|
||||
},
|
||||
_ => panic!("missing entry for {}: {}", ty, default),
|
||||
}
|
||||
|
||||
map.into()
|
||||
|
||||
Reference in New Issue
Block a user