Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add commands for moving between splits with a direction #860

Merged
merged 4 commits into from
Oct 23, 2021

Conversation

Nehliin
Copy link
Contributor

@Nehliin Nehliin commented Oct 16, 2021

Add new commands for moving between splits in a specified direction (up, down, left, right). It is something that I find really convenient in neovim when I have more than 2 splits open at the same time.

This makes it possible to add the following keymapping:

[keys.normal]
"C-l" = "jump_view_right"
"C-h" = "jump_view_left"
"C-j" = "jump_view_down"
"C-k" = "jump_view_up"

@archseer
Copy link
Member

This doesn't exactly follow a direction, it just goes to next/prev but doesn't wrap around. I think what we want would be the equivalent of ctrl-w h/j/k/l in vim which will move to the next visual direction. For example if I have two splits stacked vertically on the left, and a split on the right, moving to the right wouldn't focus the bottom-most split first but instead move to the rightmost one.

Equivalent code from sway, although I think I found a better function for it previously
https://github.com/swaywm/sway/blob/4e77bc293515ea2f00ebbc4395cb0eb4446d0195/sway/commands/focus.c#L138

@Nehliin
Copy link
Contributor Author

Nehliin commented Oct 17, 2021

@archseer Yes you are right I actually belived the neovim behaved the same way until I tested it (usually do not have horizontal splits) I can try to fix this in a bit

helix-view/src/tree.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
@Nehliin
Copy link
Contributor Author

Nehliin commented Oct 20, 2021

@archseer I'm still working on this. When testing with more complex splits I wasn't happy with my current solution in this pr because it didn't behave the way I would expect as a user. I have a new solution which is more accurate in what you'd expect by looking at the splits visually. I'll update this pr when I've completed it and cleaned it up.

@Nehliin
Copy link
Contributor Author

Nehliin commented Oct 20, 2021

Now I cleaned up, it works significantly better now and always matches the movement you'd expect by looking at the splits visually so I'm much more happy with this solution even if it is a bit more complicated.

@Nehliin Nehliin requested a review from archseer October 20, 2021 21:16
helix-view/src/tree.rs Show resolved Hide resolved
helix-term/src/keymap.rs Show resolved Hide resolved
Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🎉

@archseer
Copy link
Member

Ah, looks like there's a small conflict with master. Can you resolve it? Then we should be good to merge

@Nehliin
Copy link
Contributor Author

Nehliin commented Oct 23, 2021

@archseer Fixed 👍

@archseer archseer merged commit 0f886af into helix-editor:master Oct 23, 2021
@Nehliin Nehliin deleted the goto-splits branch October 23, 2021 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants