helix: Add match operator (#34060)
This is an implementation of matching like "m i (", as well as "] (" and
"[ (" in `helix_mode` with a few supported objects and a basis for more.
Release Notes:
- Added helix operators for selecting text objects
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
co-authored by
Conrad Irwin
parent
3f80ac0127
commit
10989c702c
@@ -86,6 +86,22 @@ struct PushFindBackward {
|
||||
multiline: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// Selects the next object.
|
||||
struct PushHelixNext {
|
||||
around: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// Selects the previous object.
|
||||
struct PushHelixPrevious {
|
||||
around: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -224,6 +240,8 @@ actions!(
|
||||
PushReplaceWithRegister,
|
||||
/// Toggles comments.
|
||||
PushToggleComments,
|
||||
/// Starts a match operation.
|
||||
PushHelixMatch,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -761,6 +779,27 @@ impl Vim {
|
||||
Vim::action(editor, cx, |vim, _: &Enter, window, cx| {
|
||||
vim.input_ignored("\n".into(), window, cx)
|
||||
});
|
||||
Vim::action(editor, cx, |vim, _: &PushHelixMatch, window, cx| {
|
||||
vim.push_operator(Operator::HelixMatch, window, cx)
|
||||
});
|
||||
Vim::action(editor, cx, |vim, action: &PushHelixNext, window, cx| {
|
||||
vim.push_operator(
|
||||
Operator::HelixNext {
|
||||
around: action.around,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
Vim::action(editor, cx, |vim, action: &PushHelixPrevious, window, cx| {
|
||||
vim.push_operator(
|
||||
Operator::HelixPrevious {
|
||||
around: action.around,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
|
||||
normal::register(editor, cx);
|
||||
insert::register(editor, cx);
|
||||
|
||||
Reference in New Issue
Block a user