snippets: Vec<Snippet>,
}
+type ParallelPrimeCachesNumThreads = u8;
+
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum LinkedProject {
ProjectManifest(ProjectManifest),
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LensConfig {
+ // runnables
pub run: bool,
pub debug: bool,
+
+ // implementations
pub implementations: bool,
+
+ // references
pub method_refs: bool,
pub refs: bool, // for Struct, Enum, Union and Trait
pub enum_variant_refs: bool,
impl LensConfig {
pub fn any(&self) -> bool {
- self.implementations || self.runnable() || self.references()
+ self.run
+ || self.debug
+ || self.implementations
+ || self.method_refs
+ || self.refs
+ || self.enum_variant_refs
}
pub fn none(&self) -> bool {
};
}
+macro_rules! try_or_def {
+ ($expr:expr) => {
+ try_!($expr).unwrap_or_default()
+ };
+}
+
impl Config {
pub fn linked_projects(&self) -> Vec<LinkedProject> {
match self.data.linkedProjects.as_slice() {
}
pub fn did_save_text_document_dynamic_registration(&self) -> bool {
- let caps =
- try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default());
+ let caps = try_or_def!(self.caps.text_document.as_ref()?.synchronization.clone()?);
caps.did_save == Some(true) && caps.dynamic_registration == Some(true)
}
+
pub fn did_change_watched_files_dynamic_registration(&self) -> bool {
- try_or!(
- self.caps.workspace.as_ref()?.did_change_watched_files.as_ref()?.dynamic_registration?,
- false
+ try_or_def!(
+ self.caps.workspace.as_ref()?.did_change_watched_files.as_ref()?.dynamic_registration?
)
}
}
pub fn location_link(&self) -> bool {
- try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
+ try_or_def!(self.caps.text_document.as_ref()?.definition?.link_support?)
}
+
pub fn line_folding_only(&self) -> bool {
- try_or!(self.caps.text_document.as_ref()?.folding_range.as_ref()?.line_folding_only?, false)
+ try_or_def!(self.caps.text_document.as_ref()?.folding_range.as_ref()?.line_folding_only?)
}
+
pub fn hierarchical_symbols(&self) -> bool {
- try_or!(
+ try_or_def!(
self.caps
.text_document
.as_ref()?
.document_symbol
.as_ref()?
- .hierarchical_document_symbol_support?,
- false
+ .hierarchical_document_symbol_support?
)
}
+
pub fn code_action_literals(&self) -> bool {
try_!(self
.caps
.as_ref()?)
.is_some()
}
+
pub fn work_done_progress(&self) -> bool {
- try_or!(self.caps.window.as_ref()?.work_done_progress?, false)
+ try_or_def!(self.caps.window.as_ref()?.work_done_progress?)
}
+
pub fn will_rename(&self) -> bool {
- try_or!(self.caps.workspace.as_ref()?.file_operations.as_ref()?.will_rename?, false)
+ try_or_def!(self.caps.workspace.as_ref()?.file_operations.as_ref()?.will_rename?)
}
+
pub fn change_annotation_support(&self) -> bool {
try_!(self
.caps
.as_ref()?)
.is_some()
}
+
pub fn code_action_resolve(&self) -> bool {
- try_or!(
- self.caps
- .text_document
- .as_ref()?
- .code_action
- .as_ref()?
- .resolve_support
- .as_ref()?
- .properties
- .as_slice(),
- &[]
- )
+ try_or_def!(self
+ .caps
+ .text_document
+ .as_ref()?
+ .code_action
+ .as_ref()?
+ .resolve_support
+ .as_ref()?
+ .properties
+ .as_slice())
.iter()
.any(|it| it == "edit")
}
+
pub fn signature_help_label_offsets(&self) -> bool {
- try_or!(
+ try_or_def!(
self.caps
.text_document
.as_ref()?
.as_ref()?
.parameter_information
.as_ref()?
- .label_offset_support?,
- false
+ .label_offset_support?
)
}
+
pub fn offset_encoding(&self) -> OffsetEncoding {
if supports_utf8(&self.caps) {
OffsetEncoding::Utf8
}
fn experimental(&self, index: &'static str) -> bool {
- try_or!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?, false)
+ try_or_def!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?)
}
+
pub fn code_action_group(&self) -> bool {
self.experimental("codeActionGroup")
}
+
pub fn server_status_notification(&self) -> bool {
self.experimental("serverStatusNotification")
}
pub fn publish_diagnostics(&self) -> bool {
self.data.diagnostics_enable
}
+
pub fn diagnostics(&self) -> DiagnosticsConfig {
DiagnosticsConfig {
disable_experimental: !self.data.diagnostics_enableExperimental,
},
}
}
+
pub fn diagnostics_map(&self) -> DiagnosticsMapConfig {
DiagnosticsMapConfig {
remap_prefix: self.data.diagnostics_remapPrefix.clone(),
warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(),
}
}
+
pub fn lru_capacity(&self) -> Option<usize> {
self.data.lruCapacity
}
+
pub fn proc_macro_srv(&self) -> Option<(AbsPathBuf, Vec<OsString>)> {
if !self.data.procMacro_enable {
return None;
};
Some((path, vec!["proc-macro".into()]))
}
+
pub fn dummy_replacements(&self) -> &FxHashMap<Box<str>, Box<[Box<str>]>> {
&self.data.procMacro_ignored
}
+
pub fn expand_proc_attr_macros(&self) -> bool {
self.data.experimental_procAttrMacros
}
+
pub fn files(&self) -> FilesConfig {
FilesConfig {
watcher: match self.data.files_watcher.as_str() {
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
}
}
+
pub fn notifications(&self) -> NotificationsConfig {
NotificationsConfig { cargo_toml_not_found: self.data.notifications_cargoTomlNotFound }
}
+
pub fn cargo_autoreload(&self) -> bool {
self.data.cargo_autoreload
}
+
pub fn run_build_scripts(&self) -> bool {
self.data.cargo_runBuildScripts || self.data.procMacro_enable
}
+
pub fn cargo(&self) -> CargoConfig {
let rustc_source = self.data.rustcSource.as_ref().map(|rustc_src| {
if rustc_src == "discover" {
},
}
}
+
pub fn flycheck(&self) -> Option<FlycheckConfig> {
if !self.data.checkOnSave_enable {
return None;
};
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 {
render_colons: self.data.inlayHints_renderColons,
max_length: self.data.inlayHints_maxLength,
}
}
+
fn insert_use_config(&self) -> InsertUseConfig {
InsertUseConfig {
granularity: match self.data.assist_importGranularity {
skip_glob_imports: !self.data.assist_allowMergingIntoGlobImports,
}
}
+
pub fn completion(&self) -> CompletionConfig {
CompletionConfig {
enable_postfix_completions: self.data.completion_postfix_enable,
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!(
+ snippet_cap: SnippetCap::new(try_or_def!(
self.caps
.text_document
.as_ref()?
.as_ref()?
.completion_item
.as_ref()?
- .snippet_support?,
- false
+ .snippet_support?
)),
snippets: self.snippets.clone(),
}
}
+
pub fn assist(&self) -> AssistConfig {
AssistConfig {
snippet_cap: SnippetCap::new(self.experimental("snippetTextEdit")),
insert_use: self.insert_use_config(),
}
}
+
pub fn join_lines(&self) -> JoinLinesConfig {
JoinLinesConfig {
join_else_if: self.data.joinLines_joinElseIf,
join_assignments: self.data.joinLines_joinAssignments,
}
}
+
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,
enum_variant_refs: self.data.lens_enable && self.data.lens_enumVariantReferences,
}
}
+
pub fn hover_actions(&self) -> HoverActionsConfig {
let enable = self.experimental("hoverActions") && self.data.hoverActions_enable;
HoverActionsConfig {
goto_type_def: enable && self.data.hoverActions_gotoTypeDef,
}
}
+
pub fn highlighting_strings(&self) -> bool {
self.data.highlighting_strings
}
+
pub fn hover(&self) -> HoverConfig {
HoverConfig {
links_in_hover: self.data.hover_linksInHover,
documentation: self.data.hover_documentation.then(|| {
- let is_markdown = try_or!(
- self.caps
- .text_document
- .as_ref()?
- .hover
- .as_ref()?
- .content_format
- .as_ref()?
- .as_slice(),
- &[]
- )
+ let is_markdown = try_or_def!(self
+ .caps
+ .text_document
+ .as_ref()?
+ .hover
+ .as_ref()?
+ .content_format
+ .as_ref()?
+ .as_slice())
.contains(&MarkupKind::Markdown);
if is_markdown {
HoverDocFormat::Markdown
}
pub fn semantic_tokens_refresh(&self) -> bool {
- try_or!(self.caps.workspace.as_ref()?.semantic_tokens.as_ref()?.refresh_support?, false)
+ try_or_def!(self.caps.workspace.as_ref()?.semantic_tokens.as_ref()?.refresh_support?)
}
+
pub fn code_lens_refresh(&self) -> bool {
- try_or!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?, false)
+ try_or_def!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?)
}
+
pub fn insert_replace_support(&self) -> bool {
- try_or!(
+ try_or_def!(
self.caps
.text_document
.as_ref()?
.as_ref()?
.completion_item
.as_ref()?
- .insert_replace_support?,
- false
+ .insert_replace_support?
)
}
+
pub fn client_commands(&self) -> ClientCommandsConfig {
let commands =
try_or!(self.caps.experimental.as_ref()?.get("commands")?, &serde_json::Value::Null);
}
}
+// Deserialization definitions
+
#[derive(Deserialize, Debug, Clone, Copy)]
#[serde(rename_all = "snake_case")]
enum SnippetScopeDef {
AllSymbols,
}
-type ParallelPrimeCachesNumThreads = u8;
-
macro_rules! _config_data {
(struct $name:ident {
$(