This adds an option to set the split direction for both the horizontal
splits, and the vertical splits.
A couple of things to look for when reviewing:
* The `derive` keywords on the Enums were copy pasted, no clue what they
should be
* Tried adding tests for this, but got stuck.
Co-authored with @Tobbe
Fixes: https://github.com/zed-industries/zed/issues/11342
Release Notes:
- vim: Added `gf` command to open files under the cursor.
- Filenames can now be `cmd`/`ctrl`-clicked, which opens them.
TODOs:
- [x] `main_test.go` <-- works
- [x] `./my-pkg/my_pkg.go` <-- works
- [x] `../go.mod` <-- works
- [x] `my-pkg/my_pkg.go` <-- works
- [x] `my-pkg/subpkg/subpkg_test.go` <-- works
- [x] `file\ with\ space\ in\ it.txt` <-- works
- [x] `"file\ with\ space\ in\ it.txt"` <-- works
- [x] `"main_test.go"` <-- works
- [x] `/Users/thorstenball/.vimrc` <-- works, but only locally
- [x] `~/.vimrc` <--works, but only locally
- [x] Get it working over collab
- [x] Get hover links working
Demo:
https://github.com/user-attachments/assets/26af7f3b-c392-4aaf-849a-95d6c3b00067
Collab demo:
https://github.com/user-attachments/assets/272598bd-0e82-4556-8f9c-ba53d3a95682
Closes#13579
A major painpoint in the Vim crate has been life-cycle management. We
used to have one global Vim instance that tried to track per-editor
state; this led to a number of subtle issues (e.g. #13579, the mode
indicator being global, and quick toggling between windows letting vim
mode's notion of the active editor get out of sync).
This PR changes the internal structure of the code so that there is now
one `Vim` instance per `Editor` (stored as an `Addon`); and the global
stuff is separated out. This fixes the above problems, and tidies up a
bunch of the mess in the codebase.
Release Notes:
* vim: Fixed accidental visual mode in project search and go to
references
([#13579](https://github.com/zed-industries/zed/issues/13579)).
Closes#15860
Since rust std now supports LazyLock replacing lazy_static with it
reduce the external dependency.
Release Notes:
- N/A
---------
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
For future reference: WIP branch of copy/pasting a mixture of images and
text: https://github.com/zed-industries/zed/tree/copy-paste-images -
we'll come back to that one after landing this one.
Release Notes:
- You can now paste images into the Assistant Panel to include them as
context. Currently works only on Mac, and with Anthropic models. Future
support is planned for more models, operating systems, and image
clipboard operations.
---------
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Jason <jason@zed.dev>
Co-authored-by: Kyle <kylek@zed.dev>
This makes sure that the `vertical_scroll_margin` doesn't leave the
cursor out of screen or somewhere it shouldn't go when it's higher than
the visible lines on screen.
So we cap it to `visible_line_count / 2`, similar to nvim:
5aa1a9532c/src/nvim/window.c (L6560)Fixes#15101
Release Notes:
- Fixed `ctrl-u`/`ctrl-d` in Vim mode not working correctly when
`vertical_scroll_margin` is set to a really high value.
Co-authored-by: Bennet <bennet@zed.dev>
When setting `"vertical_scroll_margin": 99` or other high values this
can lead to a panic that crashes Zed.
Release Notes:
- vim: Fixed a possible panic that could happen when using a very high
value for `vertical_scroll_margin` that exceeded the number of visible
lines on the screen.
Co-authored-by: Bennet <bennet@zed.dev>
Vim digraphs are a way to insert special characters using sequences of
two ASCII characters. I've implemented the feature using a new `Digraph`
operator, following the example of `AddSurrounds`. There are still a few
issues that I'm not sure what the best way to resolve them is.
- To insert `ş`, the user must pause between pressing `ctrl-k` and `s
,`, otherwise it triggers the binding for `ctrl-k s`. Is there a way to
disable `ctrl-k *` bindings while in insert, replace or waiting mode?
- Is there a better way to insert a string at all of the cursors? At the
moment I'm constructing the edits manually.
- The table of default digraphs is a 1.4k line rust expression. Is this
okay as long as it's in its own module?
- I'd like a second opinion on how best to structure the settings.json
entry.
- I have omitted the "meta character" feature as I don't think it makes
sense when editing UTF-8 text.
Release Notes:
- Added support for Vim digraphs.
Resolves#11871
Still TODO:
* [x] hide this UI unless you have some ssh projects in settings
* [x] add the "open folder" flow with the new open picker
* [ ] integrate with recent projects / workspace restoration
Release Notes:
- N/A
Minor bug where the command count overflows when enough digits are
entered. This swaps out simple multiplication/addition for their checked
counter parts, falling back to the previous value in case of overflow.
Release Notes:
- N/A
<img width="624" alt="image"
src="https://github.com/user-attachments/assets/f492b0bd-14c3-49e2-b2ff-dc78e52b0815">
- [x] Correctly set custom model token count
- [x] How to count tokens for Gemini models?
- [x] Feature flag zed.dev provider
- [x] Figure out how to configure custom models
- [ ] Update docs
Release Notes:
- Added support for quickly switching between multiple language model
providers in the assistant panel
---------
Co-authored-by: Antonio <antonio@zed.dev>
### Summary
This PR adds support for count and object motions to the toggle comments
action in Vim mode. The relevant issue is
[#14337](https://github.com/zed-industries/zed/issues/14337).
For example, `2 g c j` will toggle comments three lines downward. `g c g
g` will toggle comments from the current cursor position up to the start
of the file.
Notably missing from this PR are `g c b` (toggle comments for the
current block) as well as `g c p` (toggle comments for the current
paragraph). These seem to be non-standard.
The new module `normal/toggle_comments.rs` has been copied almost
verbatim from `normal/indent.rs`. Maybe that ought to be abstracted over
but I feel I lack the overview.
Release Notes:
- vim: Added support for count and object motion to the toggle comments
action ([#14337](https://github.com/zed-industries/zed/issues/14337)).
Simplify key dispatch code.
Previously we would maintain a cache of key matchers for each context
that
would store the pending input. For the last while we've also stored the
typed prefix on the window. This is redundant, we only need one copy, so
now
it's just stored on the window, which lets us avoid the boilerplate of
keeping
all the matchers in sync.
This stops us from losing multikey bindings when the context on a node
changes
(#11009) (though we still interrupt multikey bindings if the focus
changes).
While in the code, I fixed up a few other things with multi-key bindings
that
were causing problems:
Previously we assumed that all multi-key bindings took precedence over
any
single-key binding, now this is done such that if a user binds a
single-key
binding, it will take precedence over all system-defined multi-key
bindings
(irrespective of the depth in the context tree). This was a common cause
of
confusion for new users trying to bind to `cmd-k` or `ctrl-w` in vim
mode
(#13543).
Previously after a pending multi-key keystroke failed to match, we would
drop
the prefix if it was an input event. Now we correctly replay it
(#14725).
Release Notes:
- Fixed multi-key shortcuts not working across completion menu changes
([#11009](https://github.com/zed-industries/zed/issues/11009))
- Fixed multi-key shortcuts discarding earlier input
([#14445](https://github.com/zed-industries/zed/pull/14445))
- vim: Fixed `jk` binding preventing you from repeating `j`
([#14725](https://github.com/zed-industries/zed/issues/14725))
- vim: Fixed `escape` in normal mode to also clear the selected
register.
- Fixed key maps so user-defined mappings take precedence over builtin
multi-key mappings
([#13543](https://github.com/zed-industries/zed/issues/13543))
- Fixed a bug where overridden shortcuts would still show in the Command
Palette
Fix: #14242
At present, we don't trigger the method `start_recording(cx)` to start
recording when typing add_surround, so it can't be repeated well, delete
and change actually don't increase, but when entering `d` and `c`, it
happens that these two operations are recorded, I think maybe we also
need to call `start_recording(cx)` when calling delete_surround and
change_surround, otherwise when the user modifies their shortcuts, these
two functions may not be supported by repeat
Release Notes:
- N/A
At present, when calculating some ranges, we take the `tuple_windows` to
iterate forward, which will cause some problems when the cursor is being
front, because `tuple_windows` iteration cannot iterate to the very
beginning, so there will be some cases that cannot be calculated, adjust
this method, and now it can calculate more perfectly, and the execution
speed is about the same
Release Notes:
- N/A
Release Notes:
- vim: Added `-`/`+` to go to beginning of line above/below
([#14183](https://github.com/zed-industries/zed/issues/14183)).
- vim: (Breaking) Removed non-standard builtin binding from `-` to open
the project panel. You can re-add it to your keymap file with:
`{"context":"VimControl", "bindings":{ "-":
"pane::RevealInProjectPanel"}}`
Optionally, include screenshots / media showcasing your addition that
can be included in the release notes.
https://github.com/zed-industries/zed/assets/32429059/0e9e9348-265e-4a81-a45a-4739034dc5d9
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Release Notes:
- vim: (BREAKING) Improved vim keymap contexts.
Previously `vim_mode == normal` was true even when operators were
pending, which led to bugs like #13789 and a requirement for custom
keymaps to exclude various conditions like (`!VimObject` and
`!VimWaiting`) to avoid bugs.
Now `vim_mode` will be set to `operator` or `waiting` in these cases as
described in [the docs](https://zed.dev/docs/vim#keybindings). For most
custom keymaps this change will be a no-op or an improvement, but if you
were deliberately relying on the old behaviour (if you were relying on
`VimObject` or `VimWaiting` becoming true) you will need to update your
keymap.
---------
Co-authored-by: Thorsten <thorsten@zed.dev>
For: #13417
This is a simple version, I'm not sure if we just need to limit this
feature to vim mode, or maybe in normal editor mode, which involves
other logic like the location of the setting
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This is related to #9428
I noticed that doing a search and replace for the beginning of a line
`^` results in the trailing line being included in the search. This
seems to be because of the way the range is generated for generating
matches being the up to the start of the trailing line rather than up to
the end of the last line.
I added a test and took a stab at fixing it but it is a bit yolo as this
is the first time I've seen this codebase.
These were previously passed directly to the editor module, which knows
nothing about vim counts. Instead, implement new actions in the vim
module which take the count and use it to invoke the corresponding
action in the editor module, properly repeated.
Release Notes:
- Fixed vim undo and redo commands not taking counts.
Fixing the "r" action just involved adapting `normal_replace` to replace
multiple characters.
Fixing the "shift-r" command was less straightforward. The bindings for
`vim::BeforeNormal` in replace mode were being overwritten and several
other steps required for action repetition were not performed. Finally,
the cursor adjustment after re-entering normal mode was duplicated
(`vim::BeforeNormal` was now triggered correctly) so I removed the
special case for replace mode.
Release Notes:
- Fixed vim "r" action to accept a count argument
- Fixed vim "shift-r" action to accept a count argument and allow
repetition
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Adds support for surrounding text in visual/visual-line/visual-block
mode by re-using the `AddSurrounds` operator. There is no default
binding though so the user must follow the instructions to enable it.
Note that the behaviour varies slightly for the visual-line and
visual-block modes. In visual-line mode the surrounds are placed on
separate lines (the vim-surround extension also indents the contents but
I opted not to as that behaviour is less important with the use of code
formatters). In visual-block mode each of the selected regions is
surrounded and the cursor returns to the beginning of the selection
after the action is complete.
Release Notes:
- Added action to surround text in visual mode (no default binding).
Fixes#13122
![result](https://github.com/zed-industries/zed/assets/32017007/c400081f-be5d-48fa-994f-90a00e2be359)
In the past, Zed used a single switch called `autoclose` to control both
`autoclose` and `auto_surround` functionalities:
+ `autoclose`: when input '(', append ')' automatically.
+ `auto_surround`: when select text and input '(', surround text with
'(' and ')' automatically.
This PR separates `auto_surround` from `autoclose` to support `<`.
Previously, if `autoclose` of `<` was set to `false`, `auto_surround`
couldn't be used. However, setting `autoclose` to `true` would affect
the default behavior of simple expression. For example, `a < b` would
become `a <> b`.
For more information, see #13187.
Fix#12898.
Release Notes:
- Added support for `auto_surround`
([#12898](https://github.com/zed-industries/zed/issues/12898)).