From 4a9d1163e04ba0fc29f8532afd35381b7df55e48 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 14 May 2021 19:21:46 +0900 Subject: Hacky way to specify indent scopes per language via toml configs. Can't do it via a scm query nicely because it returns an iterator over all the matches, whereas we want to traverse the tree ourselves. Can't extract the pattern data from a parsed query either. Oh well, toml files for now. --- helix-term/src/commands.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 4a42bbba..104df72f 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1171,7 +1171,13 @@ fn open(cx: &mut Context, open: Open) { let index = doc.text().line_to_char(line).saturating_sub(1); // TODO: share logic with insert_newline for indentation - let indent_level = indent::suggested_indent_for_pos(doc.syntax(), text, index, true); + let indent_level = indent::suggested_indent_for_pos( + doc.language_config(), + doc.syntax(), + text, + index, + true, + ); let indent = doc.indent_unit().repeat(indent_level); let mut text = String::with_capacity(1 + indent.len()); text.push('\n'); @@ -1649,8 +1655,13 @@ pub mod insert { let curr = contents.char(pos); // TODO: offset range.head by 1? when calculating? - let indent_level = - indent::suggested_indent_for_pos(doc.syntax(), text, pos.saturating_sub(1), true); + let indent_level = indent::suggested_indent_for_pos( + doc.language_config(), + doc.syntax(), + text, + pos.saturating_sub(1), + true, + ); let indent = doc.indent_unit().repeat(indent_level); let mut text = String::with_capacity(1 + indent.len()); text.push('\n'); -- cgit v1.2.3-70-g09d2