llakala / nixos

My NixOS config
3 stars 1 forks source link

helix: give us the ability to make select and normal identical again #59

Closed llakala closed 3 days ago

llakala commented 4 days ago

Previously, I was setting my custom normal binds and select binds to the same thing. This made sense for almost everything. But, it turns out, for my word-moving binds, they're actually different. For normal mode, they have to look like this:

 w = "move_next_word_start";
W = "move_prev_word_start";

e = "move_next_long_word_start";
E = "move_prev_long_word_start";

b = "move_next_word_end";
B = "move_prev_word_end";

n = "move_next_long_word_end";
N = "move_prev_long_word_end";

While with select, they have to look like this:

w = "extend_next_word_start";
W = "extend_prev_word_start";

e = "extend_next_long_word_start";
E = "extend_prev_long_word_start";

b = "extend_next_word_end";
B = "extend_prev_word_end";

n = "extend_next_long_word_end";
N = "extend_prev_long_word_end";

Notice the difference? For the selection binds to extend the selection, they have to use separate internal commands. Totally understandable. However, it's led to a lot of duplicated code between the two modes. Ideally, we'd be able to keep everything between the modes the same, except these two.

My immediate ideas for doing this are

Writing it as a function feels like the right way to do this, but the simplicity of using // is really calling to me. However, if we ever get into nested binds, // will cause issues, and we really don't need to introduce some deepMerge stuff. I think if we write the function in the right way, it'll be great. We just need to figure out what that right way is.

llakala commented 3 days ago

Done with 8c592f45e1fc83f14e6badac6ef68c58b5edff13. Was able to make it a function after seeing some great reference code.