Skip to content

Feature request: customizable tree layout #130

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
wookayin opened this issue Feb 6, 2022 · 11 comments
Closed

Feature request: customizable tree layout #130

wookayin opened this issue Feb 6, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@wookayin
Copy link
Contributor

wookayin commented Feb 6, 2022

image

Left: NERDTree, Mid: nvim-tree.lua, Right: NeoTree

It would be great if neotree can support customization tree layout. For example, I personally prefer the style of nvim-tree.lua (or coc-explorer) where a fancy unicode characters is used to denote the expanded tree. Compared to that, the style of NERDTree and NeoTree seem less intuitive for me.

NeoTree follows the default style of NERDTree, but it has another problem: the indent align is not proper. This is more noticable when one has some indent level guide plugin. I have a tabsize of 4 (&sw = 4) in this example -- somehow it was supposed to be 2 but I just did not have such config (although the plugin itself might want to add buffer-specific options). Please compare with that of NERDTree. It might be fixed either if (i) there is no a padding (in one space character) on the left, (ii) if no space/tab is used with different tree drawing style (like nvim-tree), or (iii) I just don't use the indent-blankline plugin.

@wookayin
Copy link
Contributor Author

wookayin commented Feb 6, 2022

In my humble opinion, adding some configurable option/feature to choose which tree drawing style to be used would be great, but even if an user chooses the current default style the misaligned indentation would need to be fixed.

@cseickel
Copy link
Contributor

cseickel commented Feb 6, 2022

For the folder icons, that is configurable by setting the folder_open and folder_closed properties on the icon component, see:

folder_closed = "",

The problem with the indent alignment is that I pad the window with 1 space because I don't show indent lines on the tree and to me it looks better with the padding. I can certainly make that configurable. There is also a PR that is almost complete to add indent guides. I think that is stalled but I'll finish it up and get it merged.

@cseickel cseickel added the enhancement New feature or request label Feb 6, 2022
@cseickel
Copy link
Contributor

cseickel commented Feb 7, 2022

This should be handled with the changes in #131 which are now in the latest release. You should be able to get what you want with this config:

      require("neo-tree").setup({
        default_component_configs = {
          indent = {
            indent_size = 2,
            padding = 0, -- extra padding on left hand side
            with_markers = true,
            indent_marker = "",
            last_indent_marker = "",
            highlight = "NeoTreeIndentMarker",
          },
          icon = {
            folder_closed = "",
            folder_open = "",
            trailing_slash = true,
            default_icon = "*",
          },
          ...

If you have the icon component configured in your renderers as well, those settings will merge and take precedence over the default_component_configs where they conflict.

The indent component is brand new.

@cseickel cseickel closed this as completed Feb 7, 2022
@wookayin
Copy link
Contributor Author

wookayin commented Feb 7, 2022

Thanks, the new feature works very well for me.

One minor issue: Has the default_icon changed? It was * previously, and now it is just a blank, which confuses indent guide again.

@cseickel
Copy link
Contributor

cseickel commented Feb 7, 2022

I moved the default settings from the individual renderers to the global_component_config section, so you may have lost it in the transition. If you use the config I posted above then it should still apply as "*". Of course, even without that the true default is a space " " anyhow, so the spacing should be preserved.

I never actually saw the default icon getting used on my computer, web-devicons has always supplied an icon for every file. I'm suprised to see that your Makefile used the default in the screenshot above.

@wookayin
Copy link
Contributor Author

wookayin commented Feb 7, 2022

I don't think default_icon is used anywhere in the current version (this seems to be a regression). I can confirm that switching to an older version gives the correct default icon.

image

This line didn't catch up the changes in 567176f:

M.icon = function(config, node, state) 
  local icon = config.default or " "

@wookayin
Copy link
Contributor Author

wookayin commented Feb 7, 2022

Ok so this seems to be a typo. You probably have meant

 icon = {             
-  default_icon = "",
+  default = "",
 },                   

in the config (README, docs, etc.). What the default icon hard-coded (in L105) did you intend just in case default_components_config is missing?

@cseickel
Copy link
Contributor

cseickel commented Feb 7, 2022

🤦‍♂️ Good catch, thanks for finding that!

@nyngwang
Copy link

nyngwang commented Feb 8, 2022

While it works, I would like to know why with_markers = true, is needed? It took me some time to realize that I have to also set this option to true to show the markers.

@cseickel
Copy link
Contributor

cseickel commented Feb 8, 2022

@nyngwang Indent makers are just one of the possible features of indent. The other configurations exposed here are how many spaces to indent and how much padding to add.

Not everyone likes have indent markers so the default is false.

@nyngwang
Copy link

nyngwang commented Feb 8, 2022

Got it!

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