Skip to content

Commit

Permalink
Add unimpaired navigation with comment textobjects after helix-editor…
Browse files Browse the repository at this point in the history
…#1619 merged
  • Loading branch information
EpocSquadron committed Mar 4, 2022
1 parent 4bce969 commit d1d620f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
| `[c` | Go to previous class (**TS**) | `goto_prev_class` |
| `]p` | Go to next parameter (**TS**) | `goto_next_parameter` |
| `[p` | Go to previous parameter (**TS**) | `goto_prev_parameter` |
| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
| `[o` | Go to previous comment (**TS**) | `goto_prev_comment` |
| `[space` | Add newline above | `add_newline_above` |
| `]space` | Add newline below | `add_newline_below` |

Expand Down
10 changes: 10 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ impl MappableCommand {
goto_prev_class, "Goto previous class",
goto_next_parameter, "Goto next parameter",
goto_prev_parameter, "Goto previous parameter",
goto_next_comment, "Goto next comment",
goto_prev_comment, "Goto previous comment",
dap_launch, "Launch debug target",
dap_toggle_breakpoint, "Toggle breakpoint",
dap_continue, "Continue program execution",
Expand Down Expand Up @@ -5380,6 +5382,14 @@ fn goto_prev_parameter(cx: &mut Context) {
goto_ts_object_impl(cx, "parameter", Direction::Backward)
}

fn goto_next_comment(cx: &mut Context) {
goto_ts_object_impl(cx, "comment", Direction::Forward)
}

fn goto_prev_comment(cx: &mut Context) {
goto_ts_object_impl(cx, "comment", Direction::Backward)
}

fn select_textobject_around(cx: &mut Context) {
select_textobject(cx, textobject::TextObject::Around);
}
Expand Down
2 changes: 2 additions & 0 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ impl Default for Keymaps {
"f" => goto_prev_function,
"c" => goto_prev_class,
"p" => goto_prev_parameter,
"o" => goto_prev_comment,
"space" => add_newline_above,
},
"]" => { "Right bracket"
Expand All @@ -616,6 +617,7 @@ impl Default for Keymaps {
"f" => goto_next_function,
"c" => goto_next_class,
"p" => goto_next_parameter,
"o" => goto_next_comment,
"space" => add_newline_below,
},

Expand Down

0 comments on commit d1d620f

Please sign in to comment.