+ pub fn flycheck(&self) -> Option<FlycheckConfig> {
+ if !self.data.checkOnSave_enable {
+ return None;
+ }
+ let flycheck_config = match &self.data.checkOnSave_overrideCommand {
+ Some(args) if !args.is_empty() => {
+ let mut args = args.clone();
+ let command = args.remove(0);
+ FlycheckConfig::CustomCommand { command, args }
+ }
+ Some(_) | None => FlycheckConfig::CargoCommand {
+ command: self.data.checkOnSave_command.clone(),
+ target_triple: self
+ .data
+ .checkOnSave_target
+ .clone()
+ .or_else(|| self.data.cargo_target.clone()),
+ all_targets: self.data.checkOnSave_allTargets,
+ no_default_features: self
+ .data
+ .checkOnSave_noDefaultFeatures
+ .unwrap_or(self.data.cargo_noDefaultFeatures),
+ all_features: self
+ .data
+ .checkOnSave_allFeatures
+ .unwrap_or(self.data.cargo_allFeatures),
+ features: self
+ .data
+ .checkOnSave_features
+ .clone()
+ .unwrap_or_else(|| self.data.cargo_features.clone()),
+ extra_args: self.data.checkOnSave_extraArgs.clone(),
+ },
+ };
+ Some(flycheck_config)
+ }
+ pub fn runnables(&self) -> RunnablesConfig {
+ RunnablesConfig {
+ override_cargo: self.data.runnables_overrideCargo.clone(),
+ cargo_extra_args: self.data.runnables_cargoExtraArgs.clone(),
+ }
+ }
+ pub fn inlay_hints(&self) -> InlayHintsConfig {
+ InlayHintsConfig {
+ type_hints: self.data.inlayHints_typeHints,
+ parameter_hints: self.data.inlayHints_parameterHints,
+ chaining_hints: self.data.inlayHints_chainingHints,
+ max_length: self.data.inlayHints_maxLength,
+ }
+ }
+ fn insert_use_config(&self) -> InsertUseConfig {
+ InsertUseConfig {
+ merge: match self.data.assist_importMergeBehavior {
+ MergeBehaviorDef::None => None,
+ MergeBehaviorDef::Full => Some(MergeBehavior::Full),
+ MergeBehaviorDef::Last => Some(MergeBehavior::Last),
+ },
+ prefix_kind: match self.data.assist_importPrefix {
+ ImportPrefixDef::Plain => PrefixKind::Plain,
+ ImportPrefixDef::ByCrate => PrefixKind::ByCrate,
+ ImportPrefixDef::BySelf => PrefixKind::BySelf,
+ },
+ group: self.data.assist_importGroup,
+ }
+ }
+ pub fn completion(&self) -> CompletionConfig {
+ CompletionConfig {
+ enable_postfix_completions: self.data.completion_postfix_enable,
+ enable_imports_on_the_fly: self.data.completion_autoimport_enable
+ && completion_item_edit_resolve(&self.caps),
+ add_call_parenthesis: self.data.completion_addCallParenthesis,
+ add_call_argument_snippets: self.data.completion_addCallArgumentSnippets,
+ insert_use: self.insert_use_config(),
+ snippet_cap: SnippetCap::new(try_or!(
+ self.caps
+ .text_document
+ .as_ref()?
+ .completion
+ .as_ref()?
+ .completion_item
+ .as_ref()?
+ .snippet_support?,
+ false
+ )),
+ }
+ }
+ pub fn assist(&self) -> AssistConfig {
+ AssistConfig {
+ snippet_cap: SnippetCap::new(self.experimental("snippetTextEdit")),
+ allowed: None,
+ insert_use: self.insert_use_config(),
+ }
+ }
+ pub fn call_info_full(&self) -> bool {
+ self.data.callInfo_full
+ }
+ pub fn lens(&self) -> LensConfig {
+ LensConfig {
+ run: self.data.lens_enable && self.data.lens_run,
+ debug: self.data.lens_enable && self.data.lens_debug,
+ implementations: self.data.lens_enable && self.data.lens_implementations,
+ method_refs: self.data.lens_enable && self.data.lens_methodReferences,
+ refs: self.data.lens_enable && self.data.lens_references,
+ }
+ }
+ pub fn hover(&self) -> HoverConfig {
+ HoverConfig {
+ implementations: self.data.hoverActions_enable
+ && self.data.hoverActions_implementations,
+ run: self.data.hoverActions_enable && self.data.hoverActions_run,
+ debug: self.data.hoverActions_enable && self.data.hoverActions_debug,
+ goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef,
+ links_in_hover: self.data.hoverActions_linksInHover,
+ markdown: try_or!(
+ self.caps
+ .text_document
+ .as_ref()?
+ .hover
+ .as_ref()?
+ .content_format
+ .as_ref()?
+ .as_slice(),
+ &[]
+ )
+ .contains(&MarkupKind::Markdown),
+ }
+ }
+ pub fn semantic_tokens_refresh(&self) -> bool {
+ try_or!(self.caps.workspace.as_ref()?.semantic_tokens.as_ref()?.refresh_support?, false)
+ }
+ pub fn code_lens_refresh(&self) -> bool {
+ try_or!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?, false)