lambdalisue / vim-fern

🌿 General purpose asynchronous tree viewer written in Pure Vim script
MIT License
1.29k stars 50 forks source link

[feature] universal fern #402

Open ydzhou opened 2 years ago

ydzhou commented 2 years ago

I would like to see an universal fern similar to what is in this PR

We will have essentially one fern across all the buffers for this vim instance.

ydzhou commented 2 years ago

Hi I thought that PR is enough to bring back the universal fern. What is missing here?

I am willing to help on the coding side if any gap need filled.

lambdalisue commented 2 years ago

At that time, there is no right side drawer. That's why the PR probably does not support it.

ydzhou commented 2 years ago

Hi Alisue, can you take a look at the PR?

The main idea is to preserve a global copy of fern instance and always retrieve it for all the buffers. But I am not sure how vimscript handle the assignment of buffer local variable. If it is a deep copy, then maybe I need to find another way to avoid unnecessary memory wasting.

ydzhou commented 2 years ago

Looks like we are allowing both left and right drawer displayed in the same window. I am not understanding the purpose of that. But following this design choice, I create a new PR to treat the left and right drawer as two separate things. We will have one universal drawer on the left and another one on the right.

Personally I think the -right feature is confusing. My proposal is to keep only one fern drawer in one window. For example, if I run Fern . -drawer, it creates a drawer at the left side. Then I run Fern . -drawer -right, it close the existing left drawer and redraw it on the right side.

What do you think about it?

lambdalisue commented 2 years ago

Looks like we are allowing both left and right drawer displayed in the same window. I am not understanding the purpose of that. But following this design choice, I create a new PR to treat the left and right drawer as two separate things. We will have one universal drawer on the left and another one on the right.

Because fern is not just a file explorer but a general purpose tree viewer. User may want to see JSON structure or vim-iced-fern-debugger or whatever on the right side, addition to the file explorer on the left side.

Personally I think the -right feature is confusing. My proposal is to keep only one fern drawer in one window. For example, if I run Fern . -drawer, it creates a drawer at the left side. Then I run Fern . -drawer -right, it close the existing left drawer and redraw it on the right side.

If the behavior is an opt-in feature, I think it's fair enough. However, that's a bit out of the topic so the PR should be separated if you'll do it.

ydzhou commented 2 years ago

Looks like we are allowing both left and right drawer displayed in the same window. I am not understanding the purpose of that. But following this design choice, I create a new PR to treat the left and right drawer as two separate things. We will have one universal drawer on the left and another one on the right.

Because fern is not just a file explorer but a general purpose tree viewer. User may want to see JSON structure or vim-iced-fern-debugger or whatever on the right side, addition to the file explorer on the left side.

Wow, great to hear that Fern can do so many things!

Still I think, drawer concept is a little confusing to me. The reason why I discuss drawer here is because that I feel like current code has many hardcode parts to handle left and right drawer separately, yet I do not see much uniqueness of those two types of drawers. I am wondering if we can make code more generic.

My understanding is that the difference between a drawer and a Fern tree is that a drawer is unique per tab, thus it can be toggled and its content can be perserved. Is that correct? Should we just introduce a type of Fern tree called persistent tree or whatever name you prefer and make it generic? So left or right is just one of the properties (position) of this persistent tree and also universal for all tabs can be another property.

For the new tree, it can be

FRI: fern://drawer:{uuid}/{path};width=30&pos=left&universal=1&tabpage=1
lambdalisue commented 2 years ago

I'm sorry but I couldn't find the benefit of your suggestion. "Making two options generic" is not enough for me to apply massive changes to the current code.

ydzhou commented 2 years ago

Yeah not much actual customer benefits, it is more of a refactoring so that we can support more cases easier. But I understand the return on investment for this work is very uncertain and we do not need to proceed unless you are seeing a clear benefit.

ydzhou commented 1 year ago

Hi Alisue

I am thinking to introduce a feature, it looks like this. When you open a drawer, it will stay opened in other tabs. When you close a draw, it will stay closed in other tabs.

For example, I toggle the fern in this tab, then when I switch to other tabs, fern is already opened. If I toggle the fern to close, then when I switch to other tabs, there will be no fern drawer.

This feature makes fern behave similar to sidebar for file tree in some IDEs.

How do you like it?

lambdalisue commented 1 year ago

It's interesting but a bit different from the feature described in this issue I think. Please create a new feature request for clarify the feature.