mirror of https://github.com/helix-editor/helix
properly handle lsp configs as well
parent
d3fb156824
commit
a2a97f1f8f
|
@ -76,7 +76,7 @@ where
|
||||||
Ok(Option::<AutoPairConfig>::deserialize(deserializer)?.and_then(AutoPairConfig::into))
|
Ok(Option::<AutoPairConfig>::deserialize(deserializer)?.and_then(AutoPairConfig::into))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_timeout() -> u64 {
|
pub fn default_timeout() -> u64 {
|
||||||
20
|
20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,14 @@ use helix_core::{
|
||||||
diagnostic::Severity,
|
diagnostic::Severity,
|
||||||
extensions::steel_implementations::{rope_module, SteelRopeSlice},
|
extensions::steel_implementations::{rope_module, SteelRopeSlice},
|
||||||
find_workspace, graphemes,
|
find_workspace, graphemes,
|
||||||
syntax::{self, AutoPairConfig, IndentationConfiguration, LanguageConfiguration, SoftWrap},
|
syntax::{
|
||||||
|
self, default_timeout, AutoPairConfig, IndentationConfiguration, LanguageConfiguration,
|
||||||
|
LanguageServerConfiguration, SoftWrap,
|
||||||
|
},
|
||||||
text_annotations::InlineAnnotation,
|
text_annotations::InlineAnnotation,
|
||||||
Range, Selection, Tendril,
|
Range, Selection, Tendril,
|
||||||
};
|
};
|
||||||
use helix_event::register_hook;
|
use helix_event::register_hook;
|
||||||
use helix_loader::merge_toml_values;
|
|
||||||
use helix_view::{
|
use helix_view::{
|
||||||
annotations::diagnostics::DiagnosticFilter,
|
annotations::diagnostics::DiagnosticFilter,
|
||||||
document::{DocumentInlayHints, DocumentInlayHintsId, Mode},
|
document::{DocumentInlayHints, DocumentInlayHintsId, Mode},
|
||||||
|
@ -2072,6 +2074,8 @@ impl HelixConfiguration {
|
||||||
new_config.persistent_diagnostic_sources;
|
new_config.persistent_diagnostic_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::info!("{:#?}", &existing_config);
|
||||||
|
|
||||||
self.update_individual_language_config(IndividualLanguageConfiguration {
|
self.update_individual_language_config(IndividualLanguageConfiguration {
|
||||||
config: existing_config,
|
config: existing_config,
|
||||||
});
|
});
|
||||||
|
@ -2098,6 +2102,7 @@ impl HelixConfiguration {
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let mut loader = (*(*self.language_configuration.load())).clone();
|
let mut loader = (*(*self.language_configuration.load())).clone();
|
||||||
let lsp_configs = loader.language_server_configs_mut();
|
let lsp_configs = loader.language_server_configs_mut();
|
||||||
|
|
||||||
let individual_config = lsp_configs.get_mut(lsp.as_str());
|
let individual_config = lsp_configs.get_mut(lsp.as_str());
|
||||||
|
|
||||||
if let Some(config) = individual_config {
|
if let Some(config) = individual_config {
|
||||||
|
@ -2135,7 +2140,50 @@ impl HelixConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("Invalid lsp: {}", lsp);
|
let command = if let Some(command) = map.get("command") {
|
||||||
|
String::from_steelval(command)?
|
||||||
|
} else {
|
||||||
|
anyhow::bail!("LSP config missing required `command` field.");
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut config = LanguageServerConfiguration {
|
||||||
|
command,
|
||||||
|
args: Vec::new(),
|
||||||
|
environment: HashMap::new(),
|
||||||
|
config: None,
|
||||||
|
timeout: default_timeout(),
|
||||||
|
required_root_patterns: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(args) = map.get("args") {
|
||||||
|
config.args = <Vec<String>>::from_steelval(args)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(environment) = map.get("environment") {
|
||||||
|
config.environment = <HashMap<String, String>>::from_steelval(environment)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(config_json) = map.get("config") {
|
||||||
|
let serialized = serde_json::Value::try_from(config_json.clone())?;
|
||||||
|
config.config = Some(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(timeout) = map.get("timeout") {
|
||||||
|
config.timeout = u64::from_steelval(timeout)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(required_root_patterns) = map.get("required-root-patterns") {
|
||||||
|
let patterns = <Vec<String>>::from_steelval(required_root_patterns)?;
|
||||||
|
|
||||||
|
if !patterns.is_empty() {
|
||||||
|
let mut builder = globset::GlobSetBuilder::new();
|
||||||
|
for pattern in patterns {
|
||||||
|
let glob = globset::Glob::new(&pattern)?;
|
||||||
|
builder.add(glob);
|
||||||
|
}
|
||||||
|
config.required_root_patterns = Some(builder.build()?);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.language_configuration.store(Arc::new(loader));
|
self.language_configuration.store(Arc::new(loader));
|
||||||
|
|
Loading…
Reference in New Issue