Skip to content

feat(commands): add option to open top file even when nested #1218

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

Merged
merged 1 commit into from
Nov 7, 2023
Merged

feat(commands): add option to open top file even when nested #1218

merged 1 commit into from
Nov 7, 2023

Conversation

pysan3
Copy link
Collaborator

@pysan3 pysan3 commented Nov 7, 2023

This feature was asked here: #1165 (comment)

Basically to add a keybind to open the top level file of nested files without expanding it.

Could you review this as well? @@Teddytrombone


I mean to have one command that does the following:

  1. when run on a closed folder/directory -> expands it
  2. when run on a file with other files nested under it -> opens the file without expanding it
  3. when run on any other file -> opens the file

Number 2 is not possible right now as far as I know, because the built-in open command will always first expand files with nesting and then open it when you run it again on the same file.

Originally posted by @kmoschcau in #1165 (comment)

@kmoschcau
Copy link

Nice turnaround! 😀
I'm not a maintainer, but this seems good to me. If anything it could use some more documentation than just one comment in the example config, but other than that it's good.

@cseickel cseickel merged commit f053f09 into nvim-neo-tree:main Nov 7, 2023
@pysan3
Copy link
Collaborator Author

pysan3 commented Nov 7, 2023

Thanks for your feedback @kmoschcau

Unfortunately I haven't been able to follow closely with the development of Neotree recently but is there a place where this file nesting is documented? That would be a good place to add it. I'd be glad if you could add it somewhere @kmoschcau

Or we could go to the extreme and actually add a keybind for open with no expand file as default. (Maybe <c-cr> or <m-cr>?) or even make it the default behavior?? how'd you think? @cseickel

@cseickel
Copy link
Contributor

cseickel commented Nov 8, 2023

I don't think it's necessary to add a new keybind for a variation of the open command @pysan3, I really expect that most people should be customizing their mappings anyhow and this is a pretty minor thing to change.

It probably should be the default behavior though, and I think it used to be. It probably just got broken along the way. I don't use nesting so I might not have approved the change and not even noticed that a bug was added.

@pysan3
Copy link
Collaborator Author

pysan3 commented Nov 8, 2023

It probably should be the default behavior though, and I think it used to be.

Oh, I see. I'll make a new PR then.

But my fix is not convenient and if you make it the default, there'll be no way to expand the folded files by default. Is that ok?

Also, There are split open, vsplit open etc, and you mean that all should be changed right?

@cseickel
Copy link
Contributor

cseickel commented Nov 8, 2023

But my fix is not convenient and if you make it the default, there'll be no way to expand the folded files by default. Is that ok?

I think that this is the exact reason why we have a separate action for expand, so that you can expand/close nested files without opening them.

Also, There are split open, vsplit open etc, and you mean that all should be changed right?

All of the commands that use open_with_cmd already naturally support the option so it should be documented as such.

I do think that the default should be the no_expand_file=true you just added, but since it is the default you should NOT have to specify the option. I would actually rename the option to expand_nested_files which defaults to nil/false which is the opposite meaning of no_expand_file. For backwards compatibility (because I already released it 🤦🏼) we should support both options but only mention the new expand_nested_files option in the docs.

@pysan3
Copy link
Collaborator Author

pysan3 commented Nov 8, 2023

But my fix is not convenient and if you make it the default, there'll be no way to expand the folded files by default. Is that ok?

I think that this is the exact reason why we have a separate action for expand, so that you can expand/close nested files without opening them.

Do you mean toggle_node command?

Also, There are split open, vsplit open etc, and you mean that all should be changed right?

All of the commands that use open_with_cmd already naturally support the option so it should be documented as such.

I do think that the default should be the no_expand_file=true you just added, but since it is the default you should NOT have to specify the option. I would actually rename the option to expand_nested_files which defaults to nil/false which is the opposite meaning of no_expand_file. For backwards compatibility (because I already released it 🤦🏼) we should support both options but only mention the new expand_nested_files option in the docs.

OK, fixed at #1219

I flagged it as a breaking change anyway since it will break the behavior of expand being precedence from the commit was nested files were introduced.

@Teddytrombone
Copy link
Contributor

Could you review this as well? @@Teddytrombone

Sorry, I was quite busy the last days. At a first glance it looks good to me :-D

@pysan3
Copy link
Collaborator Author

pysan3 commented Nov 10, 2023

Thanks mate ;)

My bad It was moved to #1220 and it should be good to go.

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.

4 participants