-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
The basic problem
It is currently possible to configure the keymap.toml to have key sequences. For example:
[keys.normal]
a = ["ensure_selections_forward", "collapse_selection", "move_char_right", "insert_mode"]However, there isn't any mechanism for executing commands sequentially while stopping the sequence from continuing if one of the commands in the chain fail. For example,
[keys.normal]
A-N = [":sh exit 1", ":echo Still executed"]doesn't wait for :sh to finish before moving on and therefore always executes the :echo .
Note that this doesn't only concern :sh. Each command in a sequence could return something like a boolean indicating whether it did what it was supposed to, or ran into issues. For example, search_next would return false if editor.search.wrap-around was false and it did not find another match before the end of the file.
Since this is a change in behaviour from the expected default currently, this would be behind a config flag (e.g., [editor] fallible-sequences).
This might not make much sense to change at the moment and might be better suited to using the plugin system when it is ready but I wanted to know if other people might value this regardless.
Use case that made me run into this
I was trying to hack something resembling this Wezterm plugin that allows seamlessly switching between nvim windows and Wezterm panes.
I eventually got to the point where most of it was working. However, since commands in sequences can execute asynchronously and there isn't a way of early stopping if a point in the chain "fails", I didn't manage to finish it.
In the end, I had something like
A-l = [":sh wezterm-set-var HELIX_MOVED 0", "jump_view_right", ":sh wezterm-set-var HELIX_MOVED 1"]which always resulted in the last :sh being executed, regardless of whether jump_view_right actually moved to the view on the right.