nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.62k stars 210 forks source link

Inconsistent view of elements across different sources #859

Closed ghostbuster91 closed 1 year ago

ghostbuster91 commented 1 year ago

First of all, thanks for this great plugin. I really think that it makes a lot of sense to have such generic view for tree-like data structures. I have plenty of ideas what to integrate next but first I need to get familiar with the basics, hence my migration from nvim-tree.

I modified file and directory renderers slightly to my liking but I noticed that my modifications look inconsistent across different sources.

File source: image

Buffer source: image

Git source: image

Code for renderes:

renderers = {
            directory = {
                { "indent" },
                { "icon" },
                { "current_filter" },
                {
                    "container",
                    content = {
                        { "name",       zindex = 10 },
                        { "clipboard",  zindex = 10 },
                        { "git_status", zindex = 10, hide_when_expanded = true },
                        {
                            "diagnostics",
                            errors_only = true,
                            zindex = 20,
                            align = "right",
                            hide_when_expanded = true
                        },
                    },
                },
            },
            file = {
                { "indent" },
                { "icon" },
                {
                    "container",
                    content = {
                        { "name",        zindex = 10 },
                        { "clipboard",   zindex = 10 },
                        { "bufnr",       zindex = 10 },
                        { "git_status",  zindex = 10 },
                        { "modified",    zindex = 20, align = "right" },
                        { "diagnostics", zindex = 20, align = "right" },
                    },
                },
            },
        }

I also have a name component modified:

    name = {
       use_git_status_colors = false,
    }

neotree rev: 205184aa0e0f08e8a1249d9bb37b45bae85f01b9

miversen33 commented 1 year ago

The only difference I can see here is how the directory structure is displayed on the file source vs the git and buffer source. Am I missing something?

ghostbuster91 commented 1 year ago

Sorry, my description was incomplete.

Here is a list of differences:

  1. As you noticed the directory structure differs between the git source and buffer source. In the buffer source multiple directories are collapsed into a single node, while in git source every directory is its own node
  2. Even though the use_git_status_colors was disabled entries in buffer and git sources have the color applied
  3. Spacing between the file name and git status icon is different between file and git source
miversen33 commented 1 year ago

That makes sense, thanks for clarifying!

1) This is almost certainly intentional. As a file browser, the user may want to modify any of the in between directories on tree and as such, they should all be exposed as their own nodes (IE uncompressed). I don't know what setting would need to be modified for this, but IMO it should not be changed as it makes sense within the context of a "File Browser"
2) Totally missed that. That's strange, I would imagine use_git_status_colors would do exactly what its name implies. I'll take a peek this afternoon and see if I can figure out why this didn't work "as expected", though I may come back with πŸ€·β€β™‚οΈ, I am not that familiar with the codebase.
3) Ya I am not super fond of this, IMO icons should all line up the same regardless of source. My best off the cuff guess is that the git source is using or overriding different components to display its nodes. I'll poke that a bit as well and see what I can find out.

nhat-vo commented 1 year ago

@miversen33 Just to add my insights as I've been digging around in the components part. Regarding 2, git_status and buffers override the name component, so I think that's what causes this. For 3, I think it is because some calculation with the padding, which could also stems from this override.

ghostbuster91 commented 1 year ago

@nhat-vo

Regarding 2, git_status and buffers override the name component, so I think that's what causes this.

Is this how it should be? I couldn't find any settings for that in https://github.com/nvim-neo-tree/neo-tree.nvim/blob/v2.x/lua/neo-tree/defaults.lua I think that it is confusing that users are supposed to configure default_component_configs when in the end these values are not used.

@miversen33

This is almost certainly intentional. As a file browser, the user may want to modify any of the in between directories on tree and as such, they should all be exposed as their own nodes (IE uncompressed). I don't know what setting would need to be modified for this, but IMO it should not be changed as it makes sense within the context of a "File Browser"

Right, this makes sense. There is filesystem.group_empty_dirs options which does that. And for the buffer source there is indeed no reason not to group directories. However, it seems that group_empty_dirs could be also exposed for the git source, wdyt?

miversen33 commented 1 year ago

However, it seems that group_empty_dirs could be also exposed for the git source, wdyt?

I did not even realize the git source was not grouping them lol. I don't personally see an issue with adding that configuration option though I don't know the amount of work that would go into respecting it. That is likely more an @nhat-vo or @cseickel question. I don't have alot of experience in making modifications to the codebase, more so troubleshooting stuff :)

Anyway! So onto the item I said I would look into.

Taking a peek at #421, it looks like this option should go under default_component_configs.name EG

default_component_configs = {
    name = {
        use_git_status_color = false
    }
}

I can confirm that setting this here removes the git config

With the setting disabled image

And with the setting enabled image

I will take a look at the third point later tonight, I haven't spent much time looking at the git source

ghostbuster91 commented 1 year ago

@miversen33 I agree that configuring use_git_status_color like that works for the filesystem source. My problem is that it doesn't work for the other sources. Unless what you showed is the git source, then I am confused why it doesn't work for me.

Here is my configuration https://github.com/ghostbuster91/dot-files/blob/neotree/programs/neovim/config/lua/local/neotree.lua#L45

nhat-vo commented 1 year ago

Sorry for the ambiguity πŸ˜….

Regarding 2, git_status and buffers override the name component, so I think that's what causes this.

What I meant here was that currently, git_status and buffers sources are overriding the default name component, and they do not take into account the use_git_status_colors config. Just pushed #864 to fix this. Feel free to have look to see if it fixes your problem. (Side note: it is currently a PR, so you can check it out by using

    -- 'nvim-neo-tree/neo-tree.nvim' -- change this
    {'nhat-vo/neo-tree.nvim', branch = '859-components'},  -- with this

kudos to @miversen33😁)

Regarding point 3, I'm planning to refactor the padding logic to avoid these kinds of missing/redundant padding behavior. This is a bit more complicated, so I'll add this to the PR later.

Regarding point 1, #832 and #833 also refers to this config, so I think it's best to have someone work on these 3 later.

ghostbuster91 commented 1 year ago

No worries. That is all actually clear, my answer was regarding the screenshot from @miversen33.

Regarding point 3....

Awesome πŸ‘

Regarding point 1, #832 and #833

Yeah, I also saw them because I wanted to report the same things πŸ˜…

Thank you both for explaining all of that to me and working on that. Much appreciated πŸ™

miversen33 commented 1 year ago

@miversen33 I agree that configuring use_git_status_color like that works for the filesystem source. My problem is that it doesn't work for the other sources. Unless what you showed is the git source, then I am confused why it doesn't work for me.

Here is my configuration https://github.com/ghostbuster91/dot-files/blob/neotree/programs/neovim/config/lua/local/neotree.lua#L45

Ahh my bad I didn't check the git source when I did my test. It sounds like @nhat-vo is addressing that though, good catch both of you :)

ghostbuster91 commented 1 year ago

I am going to close it. The main issue about inconsistency between views has been fixed by #864 .

My point about exposing group_empy_dirs for git source is in general valid but after some consideration I decided that I like the current way of displaying things more.