aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-14 10:21:46 +0000
committerBlaž Hrastnik2021-05-14 10:21:46 +0000
commit4a9d1163e04ba0fc29f8532afd35381b7df55e48 (patch)
tree7b8413c60c267d0a06ddbfa18e1d367b4b6d2309 /helix-term/src/commands.rs
parent726072085d019b1ce9e3cdf4e1557a1148723482 (diff)
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.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs17
1 files changed, 14 insertions, 3 deletions
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');