Skip to content

Conversation

@lopi-py
Copy link
Contributor

@lopi-py lopi-py commented Mar 1, 2022

closes #118
image

@lopi-py lopi-py marked this pull request as draft March 1, 2022 14:19
@cseickel
Copy link
Contributor

cseickel commented Mar 2, 2022

Thanks for working on this! I tried it out and it works for some files, but not all. It seems like a pattern matching issue. Given this config:

        nesting_rules = {
          ["ts"] = {"d.ts", "js", "spec.ts", "html", "css", "scss" }
        },

..this will work:

test.ts
test.js

but this won't:

test-test.ts
test-test.js

Maybe add it to README.md?

I think this is an interesting enough feature to highlight on the README.

Handle entire name rules?

I think the extension logic is probably the right way to go, keeps it simple.

How to handle expand and collapse (at the moment just keeps expanded all the time)

I would expect it to behave like a folder. Personally, I would also want them to be collapsed by default. We might need to replace some node.type == "directory" checks throughout the codebase with node:has_children() now that non-folders can be expanded.

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 2, 2022

I would expect it to behave like a folder. Personally, I would also want them to be collapsed by default.

I thought it, but what if you want to open the file itself?, also I should add a component that tells you if the file have a nesting files

Thanks for working on this! I tried it out and it works for some files, but not all. It seems like a pattern matching issue. Given this config:

and yes, I think the problem is here, I'll look for all naming cases to add to the pattern

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 2, 2022

image
pattern fixed 👍 (I did notice that git integration doesn't works with that names, lmao)

@bennypowers
Copy link

FWIW, the default UI I'd expect would collapse these "dirs", but add a + icon next to (preferably overlaying, but I understand we're limited here) the file icon

@cseickel
Copy link
Contributor

cseickel commented Mar 7, 2022

FWIW, the default UI I'd expect would collapse these "dirs", but add a + icon next to (preferably overlaying, but I understand we're limited here) the file icon

I noticed in the original request, there was a screenshot showing the use of both expand/collapse icons AND the item type icons:
image

That seems like the only way to do it. The icon component would need to be aware that nesting is enabled and switch to the combo expand/collapse icon with a second filetype icon or folder icon.

@bennypowers
Copy link

bennypowers commented Mar 7, 2022

Sounds legit. I can imagine the specifics could be customizable as well

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 15, 2022

Hi, sorry inactivity, then should I set a custom icon(instead of the file icon itself) if file is file has nesting files?

@bennypowers
Copy link

Hi, sorry inactivity, then should I set a custom icon(instead of the file icon itself) if file is file has nesting files?

sounds like there should be a new icon column to the left of the existing icon, which (for now) holds the disclosure widget (>)

@cseickel
Copy link
Contributor

Hi, sorry inactivity, then should I set a custom icon(instead of the file icon itself) if file is file has nesting files?

sounds like there should be a new icon column to the left of the existing icon, which (for now) holds the disclosure widget (>)

Yes, I think that's the way. When file nesting is enabled, the folder icon should look like a folder instead of the simple triangle, and anything that has_children(), like a folder or nested file container, should have the additional triangle style expand/collapse icon to the left of the normal icon.

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 15, 2022

Sounds good

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 20, 2022

It's ok if markers are disabled(if file nesting is enabled)?, looks a bit weird
without markers:
image
with markers:
image

@cseickel
Copy link
Contributor

I think we can just fix the markers so that they extend the extra space when they need to. I'm happy to work on that separately if you want to submit this as is.

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 20, 2022

I'll try to fix it first, thanks

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 21, 2022

@cseickel I had to put the arrows into the indent component, so is fine if the arrows uses the same highlight group as the indent markers or should have a specific highlight group(might be a breaking change because it will need to change the highlight to marker_highlight & arrow_highlight config for the indent component)?
image

@cseickel
Copy link
Contributor

I'm not crazy about having the indent component doing so many different things, but I do like the way that looks. I think in the future I might try to find a way to configure overlapping components to handle things like the indent / guides / nesting component. Definitely a problem for another day though...

For now, I think you can go ahead and add the two new highlight groups, but also keep the existing highlight group which can serve as the default for both.

  local marker_highlight = config.marker_highlight or config.highlight
  local arrow_highlight = config.arrow_highlight or config.highlight

That way there's no breaking change.

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 21, 2022

Oh, yeah

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 21, 2022

@cseickel could you check it if works fine?, then I just need add it to README.md and update the docs
also I have fixed the first issue of #186
(arrows can be enabled with indent.with_arrows, also if it is set to false and file nesting is enabled, the arrows will be enabled)

@cseickel
Copy link
Contributor

I gave it a quick try and it works well.

One thing I would change is that it didn't feel intuitive to have to turn on the with_arrows property in the indent component. I think that can be implicit and can just be set to true in setup() if the value is currently nil and nesting_rules is truthy. On the off chance that someone wants nesting but not expanders, they can explicitly set that value to false. This option can be a side note in the vim docs.

Also, on the same topic, I think I prefer the term expanders over arrows, because someone may use a different icon that doesn't happen to be an arrow.

All in all, this looks really awesome!

@bennypowers
Copy link

really jazzed to try this out

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 21, 2022

All in all, this looks really awesome!

Thanks!

Also, on the same topic, I think I prefer the term expanders over arrows, because someone may use a different icon that doesn't happen to be an arrow.

Something like this?

require("neo-tree").setup({
  expander = {
    enabled = true, -- if nil and file nesting is enabled, will set to true
    expanded = "", -- expanded icon
    collapsed = "", -- collapsed icon
    highlight = "NeoTreeExpander",
  }
})

(still all the logic will be into the indent marker component)

@cseickel
Copy link
Contributor

Something like this?

require("neo-tree").setup({
  expander = {
    enabled = true, -- if nil and file nesting is enabled, will set to true
    expanded = "", -- expanded icon
    collapsed = "", -- collapsed icon
    highlight = "NeoTreeExpander",
  }
})

I was originally just thinking of replacing the word "arrow" with "expander" in the indent component config:

      with_arrows = true,
      arrow_collapsed = "",
      arrow_expanded = "",

changed to:

      with_expanders = true,
      expander_collapsed = "",
      expander_expanded = "",

...but having a completely different section is probably cleaner. That entire section can just be copied right onto the indent components config during setup.

I'm just not sure if the name "expander" is obvious enough in that context. Maybe "expander_icons" or "expander_controls"? @bennypowers do you have any thoughts on this?

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 21, 2022

I have an idea, it's a bit complex(I think) but is making the expander(maybe markers too) component like other components but with "metadata"(_target = "indent"), then in setup copy it into the indent component, I think it will looks more cleaner

@cseickel
Copy link
Contributor

I have an idea, it's a bit complex(I think) but is making the expander(maybe markers too) component like other components but with "metadata"(_target = "indent"), then in setup copy it into de indent component, I think it will looks more cleaner

YES!

@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 22, 2022

@cseickel check it again please(check defaults.lua too), also I changed some defaults of icon component btw the extensions thing could be a migration, the sadly part is the documentation and the readme.md ;_;

@cseickel
Copy link
Contributor

@lopi-py You did a nice job with the extensions class, but I thought of another way last night as I was falling asleep that I'd like to discuss. This affects more than just this feature so I am going to post to the discussions and I'll @mention you when I do.

@bennypowers
Copy link

wrt naming, i don't mind "expander". another name for the top level config key that i think makes sense is "nesting"

@cseickel
Copy link
Contributor

cseickel commented Mar 23, 2022

Hey @lopi-py , sorry for all the back and forth on how to configure this. I think that the whole concept of how to handle these overlapping elements is a bigger discussion that we should take our time with, and not hold up this feature. For now, can we just go back to the simple case of adding this config to the indent component and finish it off?

    indent = {
      indent_size = 2,
      padding = 1,
      -- indent guides
      with_markers = false,
      indent_marker = "",
      last_indent_marker = "",
      highlight = "NeoTreeIndentMarker",
      -- expander config, needed for nesting files
      with_expanders = true,
      expander_collapsed = "",
      expander_expanded = "",
      expander_highlight = "NeoTreeExpander"
    },

We can refactor later once discussion #191 has had some time to hopefully gather input from more people.

@lopi-py lopi-py marked this pull request as ready for review March 23, 2022 17:48
@lopi-py
Copy link
Contributor Author

lopi-py commented Mar 23, 2022

@cseickel This can be merged I guess

@cseickel
Copy link
Contributor

Looks good, thanks!

@cseickel cseickel merged commit 9913b0d into nvim-neo-tree:main Mar 23, 2022
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.

3 participants