aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorMidnight Exigent2021-10-08 02:14:12 +0000
committerGitHub2021-10-08 02:14:12 +0000
commiteedcea7e6bdae7d18610ae8d035e7f732099e619 (patch)
tree9f016307c7550f69644133de6129b30f7e1e816d /helix-core
parent9f27be429d0b4848a01876cd0eb192f2db8a830b (diff)
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
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/Cargo.toml1
-rw-r--r--helix-core/src/syntax.rs13
2 files changed, 13 insertions, 1 deletions
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index 34cbba9f..51096453 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -28,6 +28,7 @@ arc-swap = "1"
regex = "1"
serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
toml = "0.5"
similar = "2.1"
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<Option<serde_json::Value>, D::Error>
+where
+ D: serde::Deserializer<'de>,
+{
+ Option::<toml::Value>::deserialize(deserializer)?
+ .map(|toml| toml.try_into().map_err(serde::de::Error::custom))
+ .transpose()
+}
+
#[derive(Debug, Serialize, Deserialize)]
pub struct Configuration {
pub language: Vec<LanguageConfiguration>,
@@ -45,7 +54,9 @@ pub struct LanguageConfiguration {
pub file_types: Vec<String>, // filename ends_with? <Gemfile, rb, etc>
pub roots: Vec<String>, // these indicate project roots <.git, Cargo.toml>
pub comment_token: Option<String>,
- pub config: Option<String>,
+
+ #[serde(default, skip_serializing, deserialize_with = "deserialize_lsp_config")]
+ pub config: Option<serde_json::Value>,
#[serde(default)]
pub auto_format: bool,