From 8b28bf253394b46d3846710075d635d511dc4879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 25 Mar 2021 16:53:32 +0900 Subject: [PATCH] Fix broken test. --- helix-core/src/indent.rs | 25 ++++++++++++++++++++++--- helix-core/src/syntax.rs | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 775bc8ba2..7fedb7d3d 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -293,9 +293,28 @@ where ); let doc = Rope::from(doc); - let language_config = crate::syntax::LOADER - .language_config_for_scope("source.rust") - .unwrap(); + use crate::syntax::{ + Configuration, IndentationConfiguration, Lang, LanguageConfiguration, Loader, + }; + use once_cell::sync::OnceCell; + let loader = Loader::new(Configuration { + language: vec![LanguageConfiguration { + scope: "source.rust".to_string(), + file_types: vec!["rs".to_string()], + language_id: Lang::Rust, + highlight_config: OnceCell::new(), + // + path: "../helix-syntax/languages/tree-sitter-rust".into(), + roots: vec![], + language_server: None, + indent: Some(IndentationConfiguration { + tab_width: 4, + unit: String::from(" "), + }), + }], + }); + + let language_config = loader.language_config_for_scope("source.rust").unwrap(); let highlight_config = language_config.highlight_config(&[]).unwrap(); let syntax = Syntax::new(&doc, highlight_config.clone()); let text = doc.slice(..); diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 8a8d649a7..a6b1cf618 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Configuration { - language: Vec, + pub language: Vec, } // largely based on tree-sitter/cli/src/loader.rs