Skip to content

use neo-tree as netrw replacement? #23

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

Closed
max107 opened this issue Jan 9, 2022 · 15 comments
Closed

use neo-tree as netrw replacement? #23

max107 opened this issue Jan 9, 2022 · 15 comments
Labels
enhancement New feature or request

Comments

@max107
Copy link
Contributor

max107 commented Jan 9, 2022

it's possible?

@cseickel
Copy link
Contributor

cseickel commented Jan 9, 2022

There is no built in feature to enable this behavior. It could always be added if enough people are interested.

@cseickel cseickel added enhancement New feature or request gauging-interest This will happen if enough people express interest in this feature. labels Jan 9, 2022
@nyngwang
Copy link

@cseickel When I run nvim MyFolder it's netrw be opened. I would like to have neo-tree to be opened.

@cseickel
Copy link
Contributor

@max107 @nyngwang @danilshvalov
Question for anyone following this issue, now or in the future: If Neo-tree opens when you open a directory in nvim instead of netrw, what then happens when you open a file from the tree?

A. The current behavior, which is to create a split for the file you open and make Neo-tree a sidebar.
B. Behave like netrw and have the file take over the current window.

Second question, is the netrw replacement request:

C. mostly about what happens when opening a directory, or
D. mostly allowing the tree to be browsed in place of the target window instead of as a separate sidebar
E. equally about both aspects of netrw

@nyngwang
Copy link

nyngwang commented Jan 23, 2022

[...] when you open a file from the tree?

A. The current behavior, which is to create a split for the file you open and make Neo-tree a sidebar.
B. Behave like netrw and have the file take over the current window.

@cseickel

My case is not considered: Most of the time I prefer to run nvim proj_folder instead of nvim proj_file. I will provide my answer to C,D,E after this is resolved. (But yeah, since the following is my real experience in the past four months with nvim-tree.lua, I think this might help to answer C,D,E)

In my opinion, nvim-tree.lua does this right with the following behavior:

  1. When I run nvim proj_folder, we will arrive at the result of B you described.
  2. Then I press my keycomb. to (toggle-)close the filetree. Now what is left is the first/only window created with a [No Name]-buffer loaded.
  3. Finally, I press my keycomb. again to (toggle-)open the filetree, then now the tree is placed at the right position the user setup(yup in my case is on the "right" position), which is the result of A you described.

Explanation: The advantage of this behavior is that: I can just press my keycomb. twice, so only one command is needed, to have both results of A and B. That is: If I want to further move the tree to the preferred side then I will run the toggle twice. Otherwise, I just run it once.

@cseickel
Copy link
Contributor

@nyngwang I think what you are saying, based on this and other conversations, is that you want to fluidly move between netrw style, sidebar, and floats depending on the situation. Is that accurate?

I don't think I posed the first question clearly. Let me restate to make sure there is no misunderstanding:

  1. You open nvim with nvim project_folder
  2. The only window is Neo-tree, opened to the folder you specified just like netrw would do
  3. You find the file you want to open and open it.
  4. Does that file now:
    A. open in a split, leaving Neo-tree as a sidebar in your preferred position?
    B. take over the current window, replacing Neo-tree?

I think it sounds like you choose A and C, because it is the most open ended solution that is the quickest path to "all of the above"

@nyngwang
Copy link

nyngwang commented Jan 23, 2022

is that you want to fluidly move between netrw style, sidebar, and floats depending on the situation. Is that accurate?

The problem of nvim-tree.lua is that it doesn't provide a floating version this sentence is somehow not that accurate.

You find the file you want to open and open it.

@cseickel Not really. I prefer to first move the tree to the right position I like before I would make a decision on which file I want to open. (Since this line is more important, I tag you here)

Why? Personally, I do this because when the filetree occupies the entire window, the content is left-aligned, but I like to be shown near the center of my screen (so why I set my the default position on the right side)

@cseickel
Copy link
Contributor

Why? Personally, I do this because when the filetree occupies the entire window, the content is left-aligned, but I like to be shown near the center of my screen (so why I set my the default position on the right side)

That was the missing piece of information that was confusing me! Wouldn't it be more efficient if step 2 was changed so that:

  1. You open nvim with nvim project_folder
  2. There is an empty buffer, with Neo-tree also open and focused in your preferred position, as specified in your config (left, right, or float)
  3. You find the file you want to open and open it.
  4. Nothing unusual happens here...

@nyngwang
Copy link

@cseickel: I like this one :) I think people would like to see everything organized "their-way" before making the first decision too!

@cseickel
Copy link
Contributor

OK, here's a proposal on how to handle these requests:

  • Add a hijack_netrw option that makes Neo-tree handle opening directories
  • In that situation, Neo-tree will open as specified in your config
  • Add a new window.position value as an option in that config: in-place, meaning netrw style in the same window where it was called from
  • Include new vim command variations that allow overriding your default position with whatever suits you at the moment, to be handled in Add more variations for open commands #31
  • If Neo-tree was opened with a position of in-place, then files will opened in the same window. If not, it will pick a window using the current logic designed for sidebars and floats.

I think this covers all possible variations of what people may want. I'll let this sit for at least a few days to collect comments.

@cseickel cseickel removed the gauging-interest This will happen if enough people express interest in this feature. label Jan 26, 2022
@cseickel cseickel pinned this issue Jan 28, 2022
@cseickel
Copy link
Contributor

Status update: I released part of this solution, which is that Neo-tree now hijacks netrw automatically. It will open in whatever position you have specified in your config when you open a directory in nvim. If anyone actually wants to use netrw as an option, let me know and I'll put in a flag to disable this functionality.

What we don't have yet is the new "in-place" position option, we are still limited to sidebar or floating window. I am still working on the "in-place" option.

@cseickel
Copy link
Contributor

cseickel commented Feb 5, 2022

This is in main right now and I think it is done. I changed the position name from "in-place" to "split". If you want to use netrw style all the time, set "split" as your position:

require("neo-tree").setup({
  filesystem = {
    window = {
      position = "split",
    },
  }
})

If you only want to use it as "split" style sometimes, use the new "InSplit" commands:

NeoTreeRevealInSplit
NeoTreeRevealInSplitToggle
NeoTreeShowInSplit
NeoTreeShowInSplitToggle

@max107
Copy link
Contributor Author

max107 commented Feb 8, 2022

image

steps to reproduce:

nvim .

image

@cseickel
Copy link
Contributor

cseickel commented Feb 8, 2022

@max107 I think this bug is the same as #133 and is fixed in main with the last commit.

@max107
Copy link
Contributor Author

max107 commented Feb 8, 2022

@cseickel i updated neo-tree to latest commit and problem still exists

@cseickel
Copy link
Contributor

cseickel commented Feb 8, 2022

@max107 I think I got it this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants