zed icon indicating copy to clipboard operation
zed copied to clipboard

Helix keymap

Open humb1t opened this issue 1 year ago • 32 comments

I know it can be tricky, but the only reason preventing me from day to day use of zed is Helix with their beautiful system based on keys without mouse, multiple selections and other features.

Will be great to support that and maybe I will try to research possible ways to do so: https://docs.helix-editor.com/keymap.html

humb1t avatar Jul 04 '23 10:07 humb1t

Zed is pretty awesome and support for the helix bindings would be nice. Can we do a bounty for someone from the community/core to get this running? I am not so skilled myself 😀.

I can do $100 for anything helix bindings related.

3210jr avatar Jan 01 '24 16:01 3210jr

Zed is pretty awesome and support for the helix bindings would be nice. Can we do a bounty for someone from the community/core to get this running? I am not so skilled myself 😀.

I can do $100 for anything helix bindings related.

Hey @3210jr - this is an extremely nice gesture; if I had to guess, I think the biggest blocker isn't that someone doesn't want to do it, it is probably more that at the moment, contributing to keymaps is a bit awkward at the moment. We don't have documentation on what all the contexts are, the source code of Zed is closed (not for much longer 🥳), the keymaps repository is simply a mirror of the internal files in Zed, so changes made to either end have to be manually copied and pasted between repos. It's all just very awkward and sort of hard to do. Someone could still do it for sure, but the process is kind of ugly and not user friendly. I imagine that once we are open source, and once we move keymaps into some sort of user-accessible directory, or plugin system, that we will have a lot more fixes to existing keymaps, and new keymaps in general, coming in.

JosephTLyons avatar Jan 01 '24 17:01 JosephTLyons

Zed + Helix would be extremely nice :3

nyabinary avatar Jan 24 '24 18:01 nyabinary

I would absolutely love to have this. I've been using Helix as my main editor for several months. Having a GUI with the same ergonomics would be fantastic.

alphabitserial avatar Jan 26 '24 11:01 alphabitserial

Now that the repository has been open-sourced, what would be a rough outline of adding Helix keymap support? 🙂

seanchen1991 avatar Jan 29 '24 14:01 seanchen1991

I would absolutely love to have this. I've been using Helix as my main editor for several months. Having a GUI with the same ergonomics would be fantastic.

I'm in the same spot but have to say, that i'll stick to helix itself. Tried helix - binding in vscode but still it's not the same experience.

danriedl avatar Jan 30 '24 16:01 danriedl

@JosephTLyons I think the request here would be to do a modal keymap that is Selection-Action instead of Action-Selection. There are multiple modal editors now (which Helix is probably one of the best) that use this model. If Zed could support it, would be really cool to see.

Another thought long term - NeoVim crew embedded their engine into VS Code. You can run the editor window using NeoVim but within the rest of VS Code. Would be very interesting for Zed to do something like this where another terminal type engine could power the editor. Maybe a chance to get the best of both worlds.

ascarter avatar Jan 30 '24 17:01 ascarter

I would like to look into this as I use Helix in preference to vim when I can. But how to do it? Is it a complete new mode? Or is it a key-binding hack on vim-mode?

andreweades avatar Jan 31 '24 08:01 andreweades

@andreweades You'd have to introduce a new helix crate to implement some of the actions, and create a new keymap to use the actions. It's distinct enough from Vim that it would probably warrant a new editing mode, because selection->action really is a distinct paradigm from action->motion. But it might be worth taking a step back and instead of just copying the Helix keymap thinking about what it might look like to design a selection->action keymap just for Zed. Most of the infrastructure is already there! Would it feel different from Kakoune and Helix given it's in a GUI editor?

clo4 avatar Feb 07 '24 13:02 clo4

Also I do like the helix bindings but I don't like to retain the selection when returning using insert mode or append mode. I have this mapped in helix a = ['append_mode', 'collapse_selection'] and i = ['insert_mode', 'collapse_selection']. I hope similar bindings can be supported in Zed.

Also vim doesn't really allow you to select the newline character (or the emptiness at the end of the buffer). Helix does. I have a hard time differentiating a whitespace from a newline in helix so I hope the cursor changes colour or something when it is on a newline character.

wmstack avatar Feb 16 '24 01:02 wmstack

+1

WarrenAdams8 avatar Feb 19 '24 05:02 WarrenAdams8

@clo4 Good point. I use a custom Helix keymap as some of my muscle memory from VIM does not translate well. I try to limit the amount of mousing as after 30+ years of mousing I have RSI in my shoulder so I like editors that have VIM and now Helix keys. I think selection->action makes a lot of sense so I would love to see it in Zed at some point and would not mind contributing when I have time.

andreweades avatar Feb 21 '24 09:02 andreweades

@JosephTLyons I wonder why this is not in the top ranking issues? It has more votes than a lot of the ones I see there. Is it because it doesn't neatly fit into one of the categories? Maybe it should be in the vim section.

wmstack avatar Mar 03 '24 05:03 wmstack

@JosephTLyons I wonder why this is not in the top ranking issues? It has more votes than a lot of the ones I see there. Is it because it doesn't neatly fit into one of the categories? Maybe it should be in the vim section.

This would only be included on the top-ranking issues report if it had more likes than the item at the bottom of the enhancement section (Git in-line blame indicators - 81 👍).

JosephTLyons avatar Mar 04 '24 05:03 JosephTLyons

i would love to have helix support inside zed 💜

how i could contribute to achieve this new crate? i'm not the very best rust developer but i think i can mimic the vim crate somehow and do some tweaks to achieve selection->action mode.

zoedsoupe avatar Jun 02 '24 22:06 zoedsoupe

@zoedsoupe There's some work at #11130, but the original author is unable to keep working on it. If you'd like to start working on that branch that would be very appreciated!

We decided to stay in the same crate as vim for now (because that way we can re-use all the mode tracking, registers, marks, test support, etc.). once we have something more close to usable we can revisit that decision if necessary.

ConradIrwin avatar Jun 02 '24 22:06 ConradIrwin

I wonder how feasible it would be to embed the helix core into zed and use that for not just helix emulation but just straight up full helix support. Similar to how neovide does it for nvim

Suya1671 avatar Jun 08 '24 10:06 Suya1671

AFAIK it is not possible now because helix does not have a splitting feature https://github.com/helix-editor/helix/issues/312 @Suyashtnt. Based on the issue's title, Kakoune does have a client-server model? If that worked it'd also mean slightly different keymaps, and no support for the Helix -> Zed windows user.

But it might be worth taking a step back and instead of just copying the Helix keymap thinking about what it might look like to design a selection->action keymap just for Zed. Most of the infrastructure is already there! Would it feel different from Kakoune and Helix given it's in a GUI editor?

sameoldlab avatar Jun 08 '24 23:06 sameoldlab

We would prefer to build helix on top of our existing CRDTs so that extensions, collaboration, etc. work properly.

ConradIrwin avatar Jun 10 '24 15:06 ConradIrwin

I know this isn't a solution, but here are my settings.json and keymap.json files in case anyone searching for this topic wants a quick fix. It's not exactly like helix of course, but decently close. I added as many keymappings from here as possible.

I've been using this for about a week and I like it, for now. I would still love to see an actual helix integration into Zed. keymap.json settings.json

ericpko avatar Jun 11 '24 12:06 ericpko

Great keymap. There are some inconsistencies but it's a great start!

One thing I noticed right away is that the basic word motions (like e and b) don't create selections, so you can't delete until the end of the word with e d in normal mode for instance. % also doesn't select the whole file, etc.

What do you say of creating a repository and working on this collaboratively?

jabcross avatar Jun 14 '24 13:06 jabcross

here are a few more ontop of @ericpko 's

      "n": "vim::PreviousWordStart",
      "b": ["workspace::SendKeystrokes", "v n"],
      "w": ["workspace::SendKeystrokes", "v e"],
      "ctrl-v": "editor::Paste",
      "shift-u": "editor::Redo", 
      "d": "vim::DeleteRight",
      "x": "editor::SelectLine"
 

garthtrickett avatar Jun 22 '24 11:06 garthtrickett

Hello, I created the repository to let everyone give some to be the closest possible https://github.com/noahfraiture/zed-helix.git @jabcross @garthtrickett @ericpko Currently I put your recommendation and I'm working on it

It would be great if it was possible to have the settings in multiple files, because currently it's pretty much impossible to directly use this repo as zed configuration file since we all have different preferences

noahfraiture avatar Jul 10 '24 15:07 noahfraiture

Hello, I created the repository to let everyone give some to be the closest possible https://github.com/noahfraiture/zed-helix.git @jabcross @garthtrickett @ericpko Currently I put your recommendation and I'm working on it

It would be great if it was possible to have the settings in multiple files, because currently it's pretty much impossible to directly use this repo as zed configuration file since we all have different preferences

loved using this, you saved my a$$, ty!

luccahuguet avatar Jul 10 '24 22:07 luccahuguet

Hello, I created the repository to let everyone give some to be the closest possible https://github.com/noahfraiture/zed-helix.git @jabcross @garthtrickett @ericpko Currently I put your recommendation and I'm working on it

It would be great if it was possible to have the settings in multiple files, because currently it's pretty much impossible to directly use this repo as zed configuration file since we all have different preferences

Maybe we should have a generator script that generates a file based on a couple questions, kind of like Powerlevel 10k

jabcross avatar Jul 11 '24 20:07 jabcross

Hello, I created the repository to let everyone give some to be the closest possible https://github.com/noahfraiture/zed-helix.git @jabcross @garthtrickett @ericpko Currently I put your recommendation and I'm working on it It would be great if it was possible to have the settings in multiple files, because currently it's pretty much impossible to directly use this repo as zed configuration file since we all have different preferences

Maybe we should have a generator script that generates a file based on a couple questions, kind of like Powerlevel 10k

As an alternative proposal, if one could point to the helix config file and translated it to zed, that way every-time you make a change in one both change. A piedra-rosetta of sorts, may be overkill and overcomplicated, but I think it would be the comfiest.

adriangalilea avatar Jul 12 '24 07:07 adriangalilea

This might be a bit out there, but has the idea of using modal editors within a terminal tab been discussed? You can currently open a terminal tab right next to a file tab, type hx 'filename' and use helix within Zed. If there were a way to just default to opening files in a terminal with a command, that might be an interesting way to easily get helix editing within the greater Zed environment. I have only played around with this, but if it were a built in feature where I could still easily add my files to LLM context I think it might just do it for me. Also could be a hotkey to switch between views? Just thinking out loud here, want to make sure this idea is at least mentioned.

smltr avatar Jul 14 '24 17:07 smltr