Commit Graph
377 Commits
Author SHA1 Message Date
Conrad Irwin acac81693e Add I and A in visual block mode 2023-08-17 11:21:58 -06:00
Conrad Irwin d37246dee7 Vim visual block mode
This isn't quite an exact emulation, as instead of using one selection
that is magically in "column mode", we emulate it with a bunch of zed
multi-selections (one per line).

I think this is better, as it requires fewer changes to the codebase,
and lets you see the impact of any changes immediately on all lines.

Fixes: zed-industries/community#984
2023-08-15 16:00:50 -06:00
Conrad Irwin 3aec608f60 Fix vim selection to include entire range (#2787)
Update vim mode to have vim selection and editor selections match.
Before this we had to adjust between vim selections and real selections
when making changes; now we have to adjust when making selections.

Release Notes:

- vim: Ensure editor selection matches the vim selection
([#1796](https://github.com/zed-industries/community/issues/1796)).
- vim: Fix `s` in visual line mode
- vim: Add `o` and `shift-o` to toggle direction of visual selection
- vim: Fix `v` and `shift-v` to toggle back to normal mode
- vim: Fix block selections like `vi}` to contain correct whitespace
2023-08-15 08:36:17 -06:00
Conrad Irwin 8e909670cd Fix vim escape in normal mode
Fixes: zed-industries/community#1857
2023-08-14 16:05:41 -06:00
Conrad Irwin e6f1a6f9a9 Merge VisualChange -> Substitute
They both are supposed to work the same.
2023-07-28 15:32:02 -06:00
Conrad Irwin 29b0f54255 Add o/O for flipping selection 2023-07-28 15:26:40 -06:00
Conrad Irwin adc89d3418 Add support for visual ranges ending with a newline
These primarily happen when first entering visual mode, but can also
be created with objects like `vi{`.

Along the way fix the way ranges like `vi{` are selected to be more
similar to nvim.
2023-07-28 15:26:40 -06:00
Conrad IrwinandMax Brunsfeld 737efc0c9d Fix vim selection to include entire range
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2023-07-28 15:26:40 -06:00
Conrad Irwin 5ddb6c1db0 vim: add , and ; 2023-07-21 09:50:22 -06:00
Conrad Irwin 0f8a1759ae Quality of life shortcuts for code actions 2023-07-21 09:47:15 -06:00
Conrad Irwin a29e2eb5d4 refactor: Remove G/Z Namespace support
This previously enabled things like `d g g` to work, but we can
fix that instead by not clearing out pending vim state on change.

Either way, it is unnecessary and causes some user-confusion
(zed-industries/community#176), so remove this code for now; and use
comments to organize the file a bit instead.
2023-07-21 09:47:14 -06:00
Conrad Irwin 94bdefefbe Fix enter in search 2023-07-20 20:48:36 -06:00
Conrad Irwin 2b63422a13 vim: Add support for ctrl-w commands
Primarily {h,j,k,l,left,right,up,down} for moving to a pane by
direction; but also {w,W,p} for going forward/back, and {v,s} for
splitting a pane vertically/horizontally, and {c,q} to close a pane.

There are a large number of ctrl-w commands that are not supported, and
which fall into three buckets:

* switch this pane with that one (VScode also has this, and it's a
  requested feature)
* move to top/bottom/leftmost/rightmost
* counts on any of these
* jump to "definition/file-under-cursor/etc.etc." in a new pane.
2023-07-19 18:29:13 -06:00
Conrad Irwin ac91fb0990 Make tab non-functional in vim mode
Fixes: zed-industries/community#988
Fixes: zed-industries/community#897
2023-07-19 10:25:17 -06:00
Conrad Irwin 8ff6450c40 Merge branch 'main' into vim-search 2023-07-19 09:48:25 -06:00
Conrad Irwin 521a8e4299 Allow ctrl+[ as an alias for escape
Also remove unneeded mappings in `g` and `z` modes

Fixes: zed-industries/community#358
2023-07-17 14:59:08 -06:00
Conrad Irwin 385cc12725 Rebuild vim search experience on refactored code 2023-07-07 15:57:54 -06:00
Conrad Irwin 1b1c0d472f vim: ? to search backwards, and /<enter> to repeat search 2023-07-07 15:57:52 -06:00
Conrad Irwin a58c6fc5e4 vim: add gD to go to type definition 2023-07-07 15:57:37 -06:00
Conrad Irwin b4a01fb7dd vim: add */#/g*/g# for jumping to next word
As in vim, this toggles the normal search experience.
2023-07-07 15:57:35 -06:00
Conrad Irwin 23ccb140d5 vim: Enter/n/N to navigate search results 2023-07-07 15:57:14 -06:00
Conrad Irwin 5978a6b221 vim: indent in visual mode uses only one <
Fixes: zed-industries/community#1562
2023-07-07 15:56:35 -06:00
Conrad Irwin eff7089db8 vim: { } to navigate by paragraph (#2668)
As part of this I added `assert_shared_state()` to the
NeovimBackedTestContext so that it is more like a drop-in replacement
for the VimTestContext.

The remaining part of zed-industries/community#682 is adding bracket
matching to plain text. It looks like the current logic requires there
to be a tree sitter language for the language in order to support
bracket matching. I didn't fix this in this PR because I was unsure
whether to try and work around that, or to try and add a plain text tree
sitter language.

Release Notes:

- vim: support `{` and `}` for paragraph motion
([#470](https://github.com/zed-industries/community/issues/470)).
- vim: fix `%` at the end of the line
([#682](https://github.com/zed-industries/community/issues/682)).
2023-07-07 14:59:06 -06:00
Conrad Irwin 97d1701e1c Remove editor::Cancel binding from vim
When you hit <escape> in the command palette, it first editor::Cancel
because the command palette is also a focused editor; this binding was
catching before the `menu::Cancel` that you probably want.

From looking at the uses of editor::Cancel it seems like the only way to
trigger this is with <escape> in an editor. Rather than trying to hook
into the existing editor cancel and add vim-specific behaviour, we'll
instead take responsibility for binding directly to <escape> when
necessary.

Fixes: zed-industries/community#1347
2023-07-03 15:26:39 -06:00
Conrad Irwin 2025d37bb2 vim: Allow ^ as a motion
Fixes: zed-industries/community#856
2023-07-03 12:55:41 -06:00
Conrad Irwin 0feef10a21 vim: ctrl-c to exit visual mode
Fixes: zed-industries/community#1447
Contributes: zed-industries/community#1089
2023-07-03 12:52:33 -06:00
Conrad Irwin dd53b256cb vim: Add }/{ for start/end of paragraph
Fixes: zed-industries/community#470
2023-06-29 23:31:22 -06:00
Nathan Sobo cb9ffd81cf vim: indent/outdent (#2644)
Release Notes:

- vim: support indent/outdent
([#832](https://github.com/zed-industries/community/issues/832>)).
2023-06-27 04:15:55 -06:00
Nathan Sobo 1a5f35c7a2 Vim toggle case (#2648)
Release Notes:

- vim: Add ~ to toggle case
([#1410](https://github.com/zed-industries/community/issues/1410))
2023-06-27 04:13:24 -06:00
Nathan Sobo 8f7fa752cd Merge remote-tracking branch 'origin/main' into vim-indent 2023-06-27 12:09:47 +02:00
Nathan Sobo 56c6d840b3 vim: Fix scrolling (#2647)
After #2641 we noticed that scrolling didn't take a count parameter, and
a few other issues with the way that we calculated the distance to
scroll.
 
Release Notes:

- Improved distance calculations for page-up/page-down
- vim: Allow counts to work with scrolling shortcuts.
2023-06-27 04:01:14 -06:00
Nathan Sobo 0f08a5223d vim: shortcuts for tab navigation (#2649)
Release Notes:

- vim: added gt/ctrl-pagedown and gT/ctrl-pageup for tab navigation
2023-06-27 03:57:01 -06:00
Conrad Irwin 19ac999fc4 vim: Fix code actions menu
Fixes: zed-industries/community#1690
2023-06-26 21:46:06 -06:00
Conrad Irwin 72df76d5f0 vim: Add ~ to change case
Fixes: zed-industries/community#1410
2023-06-26 20:22:24 -06:00
Conrad Irwin e6d5841335 vim: shortcuts for tab navigation 2023-06-26 15:07:19 -06:00
Conrad Irwin 04a35ae515 vim: Fix scrolling
After #2641 we noticed that scrolling didn't take a count parameter.

The PageDown/PageUp logic was also broken by an additional -1 (for both
vim mode and not).
2023-06-26 13:29:14 -06:00
Conrad Irwin 47563405d7 vim: indent/outdent
Fixes: zed-industries/community#832
2023-06-26 10:08:34 -06:00
Max Brunsfeld 7739da3e85 Vim: substitute support (#2641)
Release Notes:

- vim mode now supports `s` for substitute
2023-06-23 12:58:14 -07:00
Conrad IrwinandNathan Sobo 59e3cb55a8 Add counts to subsitute (and all)
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2023-06-22 11:50:56 -06:00
Nathan Sobo 58c5d3ef11 vim: binding fixes (#2637)
Release Notes:

- In vim mode you can now use count modifiers with arrow keys (`5<down>`
will go down 5 lines).
- In vim mode `ctrl+]` and `ctrl+o` now work to go to definition and
back
2023-06-22 06:44:12 -06:00
Conrad Irwin 6e93f7407e vim: Support s on selections and with multiple cursors 2023-06-21 15:44:19 -06:00
Conrad Irwin 0d7c2a88ce vim: Add basic 's' support 2023-06-21 15:06:34 -06:00
Conrad Irwin ef79513fc6 vim: ctrl+] and ctrl+o to jump to definition and back
Equivalent to f12 and ctrl-- in non-vim mode.
2023-06-21 14:34:35 -06:00
Conrad Irwin 2d9366839f vim: Allow up/down/left/right in vim mode
The user impact of this is to 5<down> to move 5 lines at a time.
2023-06-21 14:20:39 -06:00
Nathan SoboandConrad Irwin 0ea52d851d Add shift-J binding to Vim normal mode
Co-Authored-By: Conrad Irwin <conrad.irwin@gmail.com>
2023-06-21 11:58:31 -06:00
Petros Amoiridis 4c1be53252 Apply the tab_size change to keymaps and settings 2023-04-20 14:08:30 +03:00
Kay Simmons 07b2eac2a6 add go to definition binding to vim normal mode 2023-02-27 10:23:30 -08:00
Kay Simmons 24a448f00c Fix enter in normal mode acting incorrectly 2023-02-23 13:40:31 -08:00
Kay Simmons 033606fa2e fix sqlez warning, introduce tab and enter bindings to vim for inputing tab and enter text when waiting for text 2023-02-13 13:50:37 -08:00
Kay Simmons ab5653a76f More vim fixes and move some more things out of app.rs 2023-02-13 13:50:37 -08:00