Commit Graph

82 Commits

Author SHA1 Message Date
Vishal Bhavsar
96dcc385dd
vim: Implement Go To Previous Word End (#7505)
Activated by keystrokes g-e.



Release Notes:

- vim: Added `ge` and `gE` for go to Previous Word End.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-02-15 16:15:31 -07:00
Andrew Marek
3aa4e0c90b
Fix Vim 'e' Behavior When Boundary Is Last Point on Line (#7424)
This was originally just to fix
https://github.com/zed-industries/zed/issues/4354, which I did by just
returning the previous offset in `find_boundary`.. but `find_boundary`
is used in the "insert mode" / normal editor too, so returning the
previous boundary breaks existing functionality in that case.

I was considering a new `find_boundary` function just for some of the
vim motions like this, but I thought that this is straightforward enough
and future Vim functions might need similar logic too.

Release Notes:

- Fixed https://github.com/zed-industries/zed/issues/4354
2024-02-06 20:25:56 -07:00
Vishal Bhavsar
ebdabb907a
vim: Support counts for H and L motions (#7149)
Release Notes:

- Added support for counts to `H` and `L` motions
([#4941](https://github.com/zed-industries/zed/issues/4941)).
2024-01-31 11:50:08 -07:00
Thorsten Ball
cddc0fbf92
vim: fix t not being repeatable with , (#7007)
This fixes `t` not being repeatable with `,` and `;` in normal mode.

Release Notes:

- Fixed `t` in Vim mode not being repeatable with `,` or `;`.

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-01-30 09:17:19 +01:00
Vishal Bhavsar
31e9526544
vim: Add support for moving to first, middle and last visible lines (H, L, M) (#6919)
This change implements the vim
[motion](https://github.com/vim/vim/blob/master/runtime/doc/motion.txt)
commands to move the cursor to the top, middle and bottom of the visible
view. This feature is requested in
https://github.com/zed-industries/zed/issues/4941.

This change takes inspiration from
[crates/vim/src/normal/scroll.rs](https://github.com/zed-industries/zed/blob/main/crates/vim/src/normal/scroll.rs).

A note on the behavior of these commands: Because
`NeovimBackedTestContext` requires compatibility with nvim, the current
implementation causes slightly non-standard behavior: it causes the
editor to scroll a few lines. The standard behavior causes no scrolling.
It is easy enough to account for the margin by adding
`VERTICAL_SCROLL_MARGIN`. However, doing so will cause test failures due
to the disparity between nvim and zed states. Perhaps
`NeovimBackedTestContext` should have a switch to be more tolerant for
such cases.

Release Notes:

- Added support for moving to top, middle and bottom of the screen in
vim mode (`H`, `M`, and `L`)
([#4941](https://github.com/zed-industries/zed/issues/4941)).
2024-01-29 20:58:24 -07:00
Conrad Irwin
331b6e7e6e
Support "dtx" vim key combination when "x" is immediately to the right of the cursor (#6830)
Closes #4358

The bug originates on this line:
5db7e8f89e/crates/vim/src/motion.rs (L451)

- When running "dtx" on "ˇabcx", the range to delete is 0 -> 2 ("abc")
- When running "dtx" on "abˇcx", the range to delete is 2 -> 2 ("c"), so
`new_point == point` and the function incorrectly returns `None` and "c"
is not deleted
- We need to disambiguate between the "not found" case and the "found
immediately to the right" case
- This bug does not apply to the backwards case ("dTx")

Release Notes:
- Fixed "dtx" vim key combination when "x" is immediately to the right
of the cursor (#4358)
2024-01-28 19:46:14 -07:00
Brooks Swinnerton
c0c0abae56
Add support for u and U in vim visual mode 2024-01-28 15:13:09 -05:00
Brian Strauch
5b9f15e075 add test_data 2024-01-26 20:02:59 -08:00
Conrad Irwin
4143d3a36e Work on tests 2024-01-21 22:00:35 -07:00
Conrad Irwin
0479ebc26d Don't toggle WHOLE_WORD in vim search
Fixes */# in visual mode, and avoids setting up irritating state.
2024-01-19 10:58:55 -07:00
Conrad Irwin
4e118f3dd7 Fix some cases of broken repeat in vim 2024-01-18 13:20:08 -07:00
Conrad Irwin
b495669c86 Fix neovim tests with angle brackets 2023-10-22 22:24:35 -06:00
Conrad Irwin
3cf98c4fae Add | as a bracket and a motion
Although vim/nvim doesn't have | as brackets, it's common in langauges like Rust
and Ruby, and I expect it to work.
2023-10-22 22:17:34 -06:00
Conrad Irwin
9589f5573d Fix some bugs with vim objects
- softwrap interaction
- correct selection if cursor is on opening marker
2023-10-22 21:44:34 -06:00
Conrad Irwin
1c36134cf9 Fix single column vim selections 2023-10-20 11:17:19 -06:00
Conrad Irwin
9d07561d99 Merge branch 'main' into pixel-columns 2023-10-18 23:00:56 -06:00
Conrad Irwin
cb76b2a6ad Make vim visual block work better 2023-10-18 22:23:06 -06:00
Conrad Irwin
ab050d1890 Use Horizontal ranges everywhere 2023-10-09 21:48:50 -06:00
Conrad Irwin
2d99b327fc Don't wrap on paragraphs
For zed-industries/community#2116
2023-10-06 10:32:15 -06:00
Conrad Irwin
f1c743286d Clear SelectionGoal on input 2023-10-05 09:02:52 -06:00
Conrad Irwin
a4e77af571 Fix panic in increment 2023-10-04 15:13:01 -06:00
Conrad Irwin
e7ee8a95f6
vim: Fix some dw edge cases (#3058)
Release Notes:

- vim: Fix `dw` on the last word of a line, and on empty lines.
2023-09-28 15:32:29 -06:00
Conrad Irwin
2f5eaa8475
vim increment (#3054)
- vim: add ctrl-a/ctrl-x for increment/decrement
2023-09-28 15:32:11 -06:00
Conrad Irwin
768c991909 vim: Fix some dw edge cases 2023-09-27 23:09:09 -06:00
Conrad Irwin
dd1cf5c3cf vim: add ctrl-a/ctrl-x
For zed-industries/community#1411
For zed-industries/community#619
2023-09-27 19:49:31 -06:00
Conrad Irwin
25429f760c ctrl-a/x for vim 2023-09-27 12:32:01 -06:00
Conrad Irwin
8e1bbf32be vim: Fix ctrl-u/ctrl-d
They should work by exactly half a screen, and also move the cursor.
2023-09-26 22:28:04 -06:00
Conrad Irwin
a59da3634b Fix backward search from command 2023-09-20 20:44:42 -06:00
Conrad Irwin
a25fcfdfa7 Iron out some edge-cases 2023-09-20 20:44:42 -06:00
Conrad Irwin
2d9db0fed1 Flesh out v1.0 of vim : 2023-09-20 20:44:41 -06:00
Conrad Irwin
01b2db4845 Fix vim test recording 2023-09-20 12:01:04 -06:00
Conrad Irwin
8de67fd9d9 Fix vim panic when over-shooting with j 2023-09-20 11:20:35 -06:00
Conrad Irwin
b02bd9bce1 Fix Y on last line with no trailing new line
For zed-industries/community#2044
2023-09-15 11:14:04 -06:00
Conrad Irwin
7daed1b2c3 Fix 0 used in a count 2023-09-12 09:56:23 -06:00
Conrad Irwin
76d55244a1 Clear counts when switching modes 2023-09-11 18:30:31 -06:00
Conrad Irwin
d868d00985 vim: ALlow counts on insert actions
This re-uses the existing repeat infrastructure.
2023-09-11 18:09:47 -06:00
Conrad Irwin
cee549e1ef vim: Fix count handling to allow pre/post counts
Fixes 2yy, d3d, etc.

For zed-industries/community#970
For zed-industries/community#1496
2023-09-11 14:35:47 -06:00
Conrad Irwin
5d782b6cf0
vim . to replay (#2936)
Release Notes:

- vim: Add `.` to replay
([#946](https://github.com/zed-industries/community/issues/946))
- vim: Fix `J` in visual mode, and with counts.
2023-09-08 11:52:35 -06:00
Conrad Irwin
5f897f45a8 Fix f,t on soft-wrapped lines
Also remove the (dangerously confusing) display_map.find_while
2023-09-08 10:16:46 -06:00
Conrad Irwin
8e2e00e003 add vim-specific J (with repeatability) 2023-09-07 11:08:07 -06:00
Conrad Irwin
1b1d7f22cc Add visual area repeating 2023-09-07 10:45:38 -06:00
Conrad Irwin
20f98e4d17 vim . to replay
Co-Authored-By: maxbrunsfeld@gmail.com
2023-09-06 13:49:55 -06:00
Conrad Irwin
c2c04616b4
vim S (#2929)
Release Notes:
- vim: Add `S` to substitute line ([#1897](https://github.com/zed-industries/community/issues/1897)).
2023-09-05 09:39:08 -06:00
Conrad Irwin
af12977d17 vim: Add S to substitute line
For zed-industries/community#1897
2023-09-01 13:13:59 -06:00
Conrad Irwin
d3650594c3 Fix find_{,preceding}boundary to work on buffer text
Before this change the bounday could mistakenly have happened on a soft
line wrap.

Also fixes interaction with inlays better.
2023-08-29 18:03:29 -07:00
Conrad Irwin
dee1a433dd A few more fixes for wrapped line motions 2023-08-25 14:40:04 -06:00
Conrad Irwin
20aa2a4c54 vim: Fix relative line motion
Before this change up and down were in display co-ordinates, after this
change they are in fold coordinates (which matches the vim behaviour).

To make this work without causing usabliity problems, a bunch of extra
keyboard shortcuts now work:

- vim: `z {o,c}` to open,close a fold
- vim: `z f` to fold current visual selection
- vim: `g {j,k,up,down}` to move up/down a display line
- vim: `g {0,^,$,home,end}` to get to start/end of a display line

Fixes: zed-industries/community#1562
2023-08-25 14:40:04 -06:00
Conrad Irwin
1f3e009b32 Fix zed-industries/community#1950 2023-08-25 11:34:07 -06:00
Conrad Irwin
e4794e3134 vim: Fix linewise copy of last line with no trailing newline
Along the way, delete the VimBindingTestContext by updating the
visual tests to no-longer need it.
2023-08-24 00:00:12 -06:00
Conrad Irwin
33d7fe02ee Rewrite paste
- vim: support P for paste before
- vim: support P in visual mode for paste without overriding clipboard
- vim: fix position when using `p` on text copied outside zed
- vim: fix indentation when using `p` on text copied from zed
2023-08-22 13:27:57 -06:00