vim: Add sneak motion (#22793)

A (re)continuation of https://github.com/zed-industries/zed/pull/21067. 

This takes the original implementation in
https://github.com/zed-industries/zed/pull/15572 and adds the test in
https://github.com/zed-industries/zed/pull/21067. Then, as requested in
https://github.com/zed-industries/zed/pull/21067#issuecomment-2515469185,
it documents how to map a keybinding instead of having a setting.

Closes #13858

Release Notes:

- Added support for the popular
[vim_sneak](https://github.com/justinmk/vim-sneak) plugin. This is
disabled by default and can be enabled by binding a key to the `Sneak`
and `SneakBackward` operators.

Reference:
https://github.com/justinmk/vim-sneak

---------

Co-authored-by: Kajetan Puchalski <kajetan.puchalski@tuta.io>
Co-authored-by: Aidan Grant <mraidangrant@gmail.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Nico Lehmann 2025-01-10 04:07:32 -03:00 committed by GitHub
parent 0d6a549950
commit 0b105ba8b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 301 additions and 5 deletions

View file

@ -68,6 +68,8 @@ pub enum Operator {
Object { around: bool },
FindForward { before: bool },
FindBackward { after: bool },
Sneak { first_char: Option<char> },
SneakBackward { first_char: Option<char> },
AddSurrounds { target: Option<SurroundsType> },
ChangeSurrounds { target: Option<Object> },
DeleteSurrounds,
@ -460,6 +462,8 @@ impl Operator {
Operator::Literal { .. } => "^V",
Operator::FindForward { before: false } => "f",
Operator::FindForward { before: true } => "t",
Operator::Sneak { .. } => "s",
Operator::SneakBackward { .. } => "S",
Operator::FindBackward { after: false } => "F",
Operator::FindBackward { after: true } => "T",
Operator::AddSurrounds { .. } => "ys",
@ -502,6 +506,8 @@ impl Operator {
| Operator::Mark
| Operator::Jump { .. }
| Operator::FindBackward { .. }
| Operator::Sneak { .. }
| Operator::SneakBackward { .. }
| Operator::Register
| Operator::RecordRegister
| Operator::ReplayRegister