diff options
author | Connor Lay (Clay) | 2022-06-18 21:24:01 +0000 |
---|---|---|
committer | Michael Davis | 2022-06-21 16:32:03 +0000 |
commit | 67f6c85792dbdbe0ff3f9328874c7ab23ff5569b (patch) | |
tree | 2f3be3d74b44b1639328f348042ab0484cb283dc /helix-term | |
parent | 43027d91046f79d6dc495b351cdcbfd3819cd9e1 (diff) |
text-objects: add test capture & elixir queries
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 12 | ||||
-rw-r--r-- | helix-term/src/keymap/default.rs | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index c9c8e6a9..046351a3 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -395,6 +395,8 @@ impl MappableCommand { goto_prev_parameter, "Goto previous parameter", goto_next_comment, "Goto next comment", goto_prev_comment, "Goto previous comment", + goto_next_test, "Goto next test", + goto_prev_test, "Goto previous test", goto_next_paragraph, "Goto next paragraph", goto_prev_paragraph, "Goto previous paragraph", dap_launch, "Launch debug target", @@ -4098,6 +4100,14 @@ fn goto_prev_comment(cx: &mut Context) { goto_ts_object_impl(cx, "comment", Direction::Backward) } +fn goto_next_test(cx: &mut Context) { + goto_ts_object_impl(cx, "test", Direction::Forward) +} + +fn goto_prev_test(cx: &mut Context) { + goto_ts_object_impl(cx, "test", Direction::Backward) +} + fn select_textobject_around(cx: &mut Context) { select_textobject(cx, textobject::TextObject::Around); } @@ -4141,6 +4151,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) { 'f' => textobject_treesitter("function", range), 'a' => textobject_treesitter("parameter", range), 'o' => textobject_treesitter("comment", range), + 't' => textobject_treesitter("test", range), 'p' => textobject::textobject_paragraph(text, range, objtype, count), 'm' => textobject::textobject_surround_closest(text, range, objtype, count), // TODO: cancel new ranges if inconsistent surround matches across lines @@ -4170,6 +4181,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) { ("f", "Function (tree-sitter)"), ("a", "Argument/parameter (tree-sitter)"), ("o", "Comment (tree-sitter)"), + ("t", "Test (tree-sitter)"), ("m", "Matching delimiter under cursor"), (" ", "... or any character acting as a pair"), ]; diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs index 0f0b09dd..c3695117 100644 --- a/helix-term/src/keymap/default.rs +++ b/helix-term/src/keymap/default.rs @@ -104,6 +104,7 @@ pub fn default() -> HashMap<Mode, Keymap> { "c" => goto_prev_class, "a" => goto_prev_parameter, "o" => goto_prev_comment, + "t" => goto_prev_test, "p" => goto_prev_paragraph, "space" => add_newline_above, }, @@ -114,6 +115,7 @@ pub fn default() -> HashMap<Mode, Keymap> { "c" => goto_next_class, "a" => goto_next_parameter, "o" => goto_next_comment, + "t" => goto_next_test, "p" => goto_next_paragraph, "space" => add_newline_below, }, |