aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/syntax.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r--helix-core/src/syntax.rs31
1 files changed, 10 insertions, 21 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index d3750e75..dde7e90c 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -92,7 +92,7 @@ pub struct LanguageConfiguration {
pub indent: Option<IndentationConfiguration>,
#[serde(skip)]
- pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
+ pub(crate) indent_query: OnceCell<Option<Query>>,
#[serde(skip)]
pub(crate) textobject_query: OnceCell<Option<TextObjectQuery>>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -220,17 +220,6 @@ impl FromStr for AutoPairConfig {
}
}
-#[derive(Debug, Serialize, Deserialize)]
-#[serde(rename_all = "kebab-case")]
-pub struct IndentQuery {
- #[serde(default)]
- #[serde(skip_serializing_if = "HashSet::is_empty")]
- pub indent: HashSet<String>,
- #[serde(default)]
- #[serde(skip_serializing_if = "HashSet::is_empty")]
- pub outdent: HashSet<String>,
-}
-
#[derive(Debug)]
pub struct TextObjectQuery {
pub query: Query,
@@ -404,13 +393,13 @@ impl LanguageConfiguration {
self.highlight_config.get().is_some()
}
- pub fn indent_query(&self) -> Option<&IndentQuery> {
+ pub fn indent_query(&self) -> Option<&Query> {
self.indent_query
.get_or_init(|| {
- let language = self.language_id.to_ascii_lowercase();
-
- let toml = load_runtime_file(&language, "indents.toml").ok()?;
- toml::from_slice(toml.as_bytes()).ok()
+ let lang_name = self.language_id.to_ascii_lowercase();
+ let query_text = read_query(&lang_name, "indents.scm");
+ let lang = self.highlight_config.get()?.as_ref()?.language;
+ Query::new(lang, &query_text).ok()
})
.as_ref()
}
@@ -557,7 +546,7 @@ impl Loader {
pub struct TsParser {
parser: tree_sitter::Parser,
- cursors: Vec<QueryCursor>,
+ pub cursors: Vec<QueryCursor>,
}
// could also just use a pool, or a single instance?
@@ -1180,7 +1169,7 @@ struct HighlightIter<'a> {
}
// Adapter to convert rope chunks to bytes
-struct ChunksBytes<'a> {
+pub struct ChunksBytes<'a> {
chunks: ropey::iter::Chunks<'a>,
}
impl<'a> Iterator for ChunksBytes<'a> {
@@ -1190,7 +1179,7 @@ impl<'a> Iterator for ChunksBytes<'a> {
}
}
-struct RopeProvider<'a>(RopeSlice<'a>);
+pub struct RopeProvider<'a>(pub RopeSlice<'a>);
impl<'a> TextProvider<'a> for RopeProvider<'a> {
type I = ChunksBytes<'a>;
@@ -2126,7 +2115,7 @@ mod test {
#[test]
fn test_load_runtime_file() {
// Test to make sure we can load some data from the runtime directory.
- let contents = load_runtime_file("rust", "indents.toml").unwrap();
+ let contents = load_runtime_file("rust", "indents.scm").unwrap();
assert!(!contents.is_empty());
let results = load_runtime_file("rust", "does-not-exist");