From eedcea7e6bdae7d18610ae8d035e7f732099e619 Mon Sep 17 00:00:00 2001 From: Midnight Exigent Date: Fri, 8 Oct 2021 04:14:12 +0200 Subject: Allow `language.config` (in languages.toml) to be passed in as a toml object (#807) * allow language.config (in languages.toml) to be passed in as a toml object * Change config field for languages from json string to toml object * remove indents on languages.toml config * fix: remove patch version from serde_json import in helix-core * Use same tree-sitter-zig as upstream/master--- helix-core/src/syntax.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'helix-core/src/syntax.rs') diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 547b2572..9c433f3d 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -30,6 +30,15 @@ where .transpose() } +fn deserialize_lsp_config<'de, D>(deserializer: D) -> Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + Option::::deserialize(deserializer)? + .map(|toml| toml.try_into().map_err(serde::de::Error::custom)) + .transpose() +} + #[derive(Debug, Serialize, Deserialize)] pub struct Configuration { pub language: Vec, @@ -45,7 +54,9 @@ pub struct LanguageConfiguration { pub file_types: Vec, // filename ends_with? pub roots: Vec, // these indicate project roots <.git, Cargo.toml> pub comment_token: Option, - pub config: Option, + + #[serde(default, skip_serializing, deserialize_with = "deserialize_lsp_config")] + pub config: Option, #[serde(default)] pub auto_format: bool, -- cgit v1.2.3-70-g09d2