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: z fold bindings for lists (incl. files explorer) #1250

Merged
merged 13 commits into from
Jul 5, 2023

Conversation

martin-braun
Copy link
Contributor

nvim-tree allows to copy files using c as well. Also, you can collapse all folders with W which is also a default on nvim-tree.

@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 1, 2023

Unrelated pasting line after vi{ test for #116 blocks my contribution.

@theol0403
Copy link
Member

Don't worry about the tests, they are flaky.

@martin-braun
Copy link
Contributor Author

@theol0403 How to re-trigger them?

@theol0403
Copy link
Member

I can merge on a failing test. Just ignore the results.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@martin-braun
Copy link
Contributor Author

@justinmk I agree. Let's not waste more time here. Anybody is free to adjust maps, I just added zM for collapse, since this is reasonable.

@martin-braun martin-braun reopened this Jul 2, 2023
@martin-braun martin-braun changed the title feat: collapse all and copy bindings for file explorer feat: collapse all binding for file explorer Jul 2, 2023
@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 2, 2023

@theol0403 I think it would be great to exclude "flaky" tests if they randomly fail so many times, what do you think? :)

@theol0403
Copy link
Member

I am trying to fix the tests but it is proving to be very frustrating - especially since some of the failures come from genuine timing bugs in the extension. For now, it is what it is. It's not the same flaky tests every time.

@theol0403
Copy link
Member

Just so we don't only have this one "z" binding that sticks out - is there any other z binding we could use that would make sense here? Even something like zz, zt for scrolling and any other fold+- bindings. I ask just because it feels awkward to introduce the z leader key to the possible tree bindings, but for there to only be one child.

@theol0403
Copy link
Member

theol0403 commented Jul 2, 2023

Thanks for the PR btw! When I made the current bindings I picked something that seemed logical, but drawing inspiration from neotree or nvim-tree is in my opinion ideal. You are right however that we should not waste too much time, but complete and sane defaults will always provide a better experience.

@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 3, 2023

@theol0403

but drawing inspiration from neotree or nvim-tree is in my opinion ideal.

So, you actually support my initial commit of mapping c and W? I'm torn apart, I don't mind. On one hand it feels good to apply defaults from popular tree plugins, on the other hand I have to give @justinmk props for mentioning that plugins come and go. What if we have the ultimate tree plugin tomorrow that uses c for a different behavior?

But ultimately, I don't mind really.

is there any other z binding we could use that would make sense here?

I agree, having only one z-binding is odd, but the result comes from the circumstances. Never used folding in Neovim, so lets elaborate together.

Screenshot 2023-07-03 at 05 31 00

Vim is very feature rich when it comes to fold operations, VSCode doesn't offer enough workbench.file.action commands to substitute it properly. z<CR>/z+, z./zz, z- would be great to have, but I doubt I can scroll the file explorer window without changing its selection. There is list.focusPageDown and list.focusPageUp, but it will scroll down / up with cursor movement, which is not the same.

There are also no other folding operations for the files explorer. VSCode's fold actions live under editor. and apply for that only.

@justinmk

and c is the vim convention for "change", the complete opposite of yank.

I realize this is a loose point, because c has a lot of meanings in Vim, btw. :wincmd c will close a window and not change it, so a c mapping to copy files wouldn't be as controversial as it seems. Just a reminder.


All I wanted was to provide an alternative for copy and offer a collapse all (which is very useful to get clean on the files explorer) to play nice with nvim-tree compatibility.

Maybe we just drop it and let the user come up with their own, you decide.

@theol0403
Copy link
Member

I agree that is probably too minor of a topic to keep debating about.

So, you actually support my initial commit of mapping c and W?

I'm pretty indifferent, but I agree with @justinmk on those specific points. Both c and W seem pretty random. All I was trying to say was "it is good that someone is looking at the different setups and validating the current design". In the same vein, any existing bindings that don't make sense could be deleted.

I think something like c and W is something the user should add themselves 👍

Never used folding in Neovim, so lets elaborate together.

I think we could add za/zc/zo, using list.toggle/collapse/expand.

I think all we really need is for this pr to add za/zc/zo/zM, and potentially clean up any existing bindings that don't fit in with either vanilla nvim OR nvim-tree.

Thank you for your efforts on this btw, sorry for going back and forth so much on something trivial.

@martin-braun
Copy link
Contributor Author

I think we could add za/zc/zo, using list.toggle/collapse/expand.

I will look into it later, kk.

@martin-braun martin-braun changed the title feat: collapse all binding for file explorer feat: z fold bindings for lists (incl. files explorer) Jul 4, 2023
@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 4, 2023

@theol0403 zm vs zM, what is the difference? Also I can't replicate zO, zC, zA. Should they just not work or should they fallback to lowercase maps? Lastly, zR can't be mapped, because VSCode has no list.expandAll (btw).

@theol0403
Copy link
Member

@martin-braun I suppose bind zm and zM to the same thing. Same with zO/zC/zA. All lowercase fallbacks. And yeah, seems like zR is not possible.

Copy link
Collaborator

@justinmk justinmk left a comment

Choose a reason for hiding this comment

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

Should have a one-line note about Explorer mappings in the readme.md. It's not super obvious.

@theol0403
Copy link
Member

I can merge when ready.

@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 5, 2023

@theol0403 Please review once more. If it's cool: Let's go. :)

| <kbd>z</kbd> <kbd>o</kbd> / <kbd>z</kbd> <kbd>O</kbd> | `list.expand` |
| <kbd>z</kbd> <kbd>c</kbd> | `list.collapse` |
| <kbd>z</kbd> <kbd>C</kbd> | `list.collapseAllToFocus` |
| <kbd>z</kbd> <kbd>a</kbd> / <kbd>z</kbd> <kbd>A</kbd> | `list.toggleExpand` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

To help with discovery, 1-2 line mention the readme is worth it. But the high-fidelity listing of every mapping is not worth it. Users should instead check vscode shortcuts UI to see exact mappings. The readme should just give a useful hint like:

In the vscode File Explorer some familiar vim commands are configured by default:

  • for navigation: j, k, gg, G
  • for expanding/collapsing directories: zo, zc, etc.
  • run the Preferences: Open Keyboard Shortcuts vscode command to see the complete list of keybindings.

This is a more maintainable pattern that we can follow in all sections of the readme, which will result in a less noisy, more maintainable, and still useful overview.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justinmk Would you mind doing this? I don't know which place would be the best to insert these lines. I will revert my README.md changes appropriately later.

To clarify: I liked to mention each and every keybinding, because it was done for things like gg and even Enter, too. I'm not against summarizing the bindings, but it should go beyond this PR and should involve the removal of other bindings as well imho.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, not a blocker

Copy link
Member

Choose a reason for hiding this comment

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

I do agree, but

  1. until this is cleaned up, I'd rather include the list in the readme. I'll revert myself
  2. unfortunately discovery in keybindings editor is difficult because there is no way to filter by extension

@martin-braun
Copy link
Contributor Author

Done!

@theol0403
Copy link
Member

Thanks for the PR!

@theol0403 theol0403 merged commit a86bd36 into vscode-neovim:master Jul 5, 2023
5 checks passed
@martin-braun
Copy link
Contributor Author

Revert-Revert-Inception. You're welcome. :)

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.

None yet

3 participants