0. Complete re-write? #1340
Replies: 14 comments 75 replies
-
Looking at the code, I don't think it's that broken, but these are the pain points.
For example And then
To achieve async capability, the code in this plugin passes a very VERY nested callback hell into the functions. This basically makes it pretty hard to do type analysis in the first place, and it is very difficult to assume variable lifetime. If you allow me to introduce nvim-nio as a dependency, we won't need any callbacks as it uses coroutines under the hood to make async code just like a normal code flow when wrapped with TLDR; Code wrapped inside a
But nvim-nio does not support running a shell command asyncly (so we can't call git etc) just yet, until this PR is merged. |
Beta Was this translation helpful? Give feedback.
-
I am split on this. I have far less time in the code base than yourself, @pysan3 or @nhat-vo so take my opinion with a grain of salt here. I am very much of the idea that "breaking change is bad" and I don't know how well we can perform a complete rewrite of neo-tree while promising compatibility with existing configurations, especially as we don't really have any sort of tests built for neo-tree. That said, I definitely do feel pain at times when trying working on the netman integration with Neo-tree. There is alot of "magic" going on under the hood and quite a bit of that magic is not accessible to external sources. I have far less to say about maintaining neo-tree itself as for the most part I review bugs and feature PRs and don't do a ton in the way of "this hurts, we should fix it". Additionally, neo-tree is kind of used all over the place in all kinds of configurations. Its a core component of several very popular neovim distributions and while I don't necessarily think we should develop/maintain neo-tree with that at the forefront of our mind, a complete rewrite is likely going to affect thousands of users in one way or another. I almost want to suggest a fork for that, however the fork would more or less just die (and we would end up splitting time, devs, users, etc) between the 2. Almost like we are stuck in the "how do we make legacy code hurt less" phase of the project ;) My personal opinion on this is that we go the approach @pysan3 is suggesting (very slowly) with the piecemeal updates/replaces of neo-tree. I think a bunch of the pain that goes into maintaining/developing/extending neo-tree can be addressed simply with better documentation (something I seem to recall agreeing to help with but never got around to really doing) both for users and developers. Writing good documentation is hard and sucks though which is why its usually neglected lol |
Beta Was this translation helpful? Give feedback.
-
The biggest problem is that we all don't know the difference between |
Beta Was this translation helpful? Give feedback.
-
A lot of good points have been made here, let me address some of them in no particular order: Do we need a Rewrite?I agree that I'd rather not have any breaking changes for our consumers (end users and distro maintainers), but I think it's ok to make a few changes that will affect external sources so long as it is done long with the external source maintainers. Also, i just want to clarify that I really meant that we should take the time to think about what is the ideal from a blank slate rather than "how can I patch what we have to fix one pain point at a time". That doesn't mean we ultimately re-write it but I find that leads to a better solution if you think it through that way. In the end you find a way to get from your blank slate ideas to a realistic amount of change. The many faces of configI put the config on the state because I wanted to have a system where there was one argument passed around to all functions that would contain ALL state (and I am thinking of config as state here) to make the functions simpler. That state contains the state of the source plus the global config. Anywhere you see require("neo-tree").config is probably an instance where that state object is not available for some reason and is unusual. I can see an argument to be made for always requiring config to be looked up instead of including it in the state object. That would be a significant breaking change though so it's probably not worth changing. From the point of view of adding types, the state object will be a problem because it is different for each source. That would be an area where I'd inherit the config portions and leave the rest of it dynamic. Callback hellI honestly don't see the callback hell. There's not that much asynchronous code, in in many cases the same code can be synchronous or asynchronous and providing or omitting the optional callback is the difference. This is a case here I think we would need some examples of what is wrong now, vs how it could be made better with nio, and how tha is better than plenary. |
Beta Was this translation helpful? Give feedback.
-
I don't think those are similar at all. The first one parses the git status from the git binary and forces it into a simpler representation. The second line reads that simplified representation an decides what icons/highlight to display. One thing that can change there is that we parse git into a table that is more useful than just a string so there's less parsing in the display stage.
I agree. It is a huge breaking change though so the config on state will need to be deprecated for a major release before it is removed. Internally we can ignore the config on state and also not bother to document the type of config being there to inhibit new users from referencing it.
I'm pretty sure that the filesystem is the only one that has any async at all. There are two paths that you might be able to separate and only do one: the file system scans and the git_status lookup. |
Beta Was this translation helpful? Give feedback.
-
regarding the rewrite, I agree to some degree with @cseickel
I think that the decision whether to rewrite from scratch or do it in an incremental fashion depends mostly of the amount of changes that we want to do. @pysan3 already gathered some major pain points that should be addressed. We should also think what works good in the current implementation. Once we will have such a list with both pros and cons of the current codebase we can asses which way is the optimal one. |
Beta Was this translation helpful? Give feedback.
-
How should we work with named states and share states across tabpages?Conversation starts from here: #1340 (reply in thread) 1.
From what I was imagining, we would have a config option For the case of For the case of If this is a good idea, I've implemented probly like 60% of the code now? So I'd like to share the code when I'm done and ask for help testing and giving feedbacks about the new mechanism. (btw I can easily switch the behavior of [1] so both are ok). Sharing the state across tabs is not the difficult part, but sharing the position and syncing toggle (mount/unmount window) of that state across tabs is the tricky part since windows cannot be shared across tabs. 2.With my current implementation, when user I think this is a nice usage of named states. And we can implement copy files from one dir to a whole another dir as a windfall with neo-tree ;) What do you think about this? 3.
I think this can mostly be achieved with named session but I'm not exactly sure. But I must say that if we allow both tab shared and non-shared states, the code will be pretty complex. |
Beta Was this translation helpful? Give feedback.
-
It's auto generated via this action and it uses sphinx under the hood. BTW you also get a search page ;) |
Beta Was this translation helpful? Give feedback.
-
I've added a section to introduce nvim-nio and explain how to use it. Hope this motivates you more towards the migration ;) |
Beta Was this translation helpful? Give feedback.
-
Hey @cseickel While I was rewriting A) Inside B) Right above that, when the filetype is a link, the |
Beta Was this translation helpful? Give feedback.
-
@cseickel What is the difference between |
Beta Was this translation helpful? Give feedback.
-
I think I'm ready for the first alpha test! It's still way away from official release, and lacking a lot of functionalities. With this first implementation, I mostly focused on speed and async-ability (does not block neovim's main runtime thread). For example even when using the tree with the linux kernel (or any gigantic project), you should not feel that much lag when opening the tree. I also made it so that it can do incremental update of the tree. Eg 1. git status will be lazily evaluated, and 2. When you for example toggle a large directory, the rendering will lag behind but user can interact with the tree as they want; user can toggle a different dir as well, and both will be opened when rendering is done. Could you test the code and poke around to see if the performance is good on your device? InstallI will recommend you read https://github.com/pysan3/neo-tree.nvim/blob/v4-dev/MIGRATION-v4.md#setup-lazy-for-devs to have v3 neo-tree and my dev code side-by-side, but this is an easy copy paste instead if you don't care. return {
"pysan3/neo-tree.nvim",
branch = "v4-dev",
version = false,
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "MunifTanjim/nui.nvim" },
{ "3rd/image.nvim" },
{ "pysan3/pathlib.nvim" },
{ "nvim-neotest/nvim-nio" },
{ "nvim-tree/nvim-web-devicons" },
},
opts = {
-- ...
}
} Things that are not implemented yet
Node SortingNodes are only sorted alphabetically now. No config options are respected. SearchI'd like to reimplement this so all sources will automatically have searching ability without any additional code to each sources. Command CompletionNo auto completion after the For more details please read https://github.com/pysan3/neo-tree.nvim/blob/v4-dev/MIGRATION-v4.md#road-map. |
Beta Was this translation helpful? Give feedback.
-
@cseickel As https://www.reddit.com/r/neovim/s/i75dYg7gmT It's seriously gonna be a pain in the * but we have to take into account that other plugins may also be using this option, meaning we can't rely on I'm very pessimistic that it'll work well with |
Beta Was this translation helpful? Give feedback.
-
Sneak peek; search is gonna be buttery smooth + it will be integrated to all sources for free ;) record.mp4 |
Beta Was this translation helpful? Give feedback.
-
So @pysan3 has proposed several refactors, many of which involve breaking changes, and I'm starting to think that maybe what we should be doing is to start with a clean slate and design the perfect system, knowing what we do now. Maybe it's highly compatible with existing configs and maybe not. Either way it's better to think up the ideal first. After we have an ideal target, we can think about how to get there from where we are now. Maybe that means incremental changes and maybe it means starting from a clean slate and copying selectively from the existing code.
The problem is that even though I am proposing it and I think it is the right way to go, I don't really have the time to personally execute on this. I can do some of it though, if others are interested in this undertaking.
@pysan3
@miversen33
@nhat-vo
@ghostbuster91
@mrbjarksen
Beta Was this translation helpful? Give feedback.
All reactions