Skip to content

[Feature/Bug] Show hidden files by default #71

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
levouh opened this issue Jan 18, 2022 · 14 comments
Closed

[Feature/Bug] Show hidden files by default #71

levouh opened this issue Jan 18, 2022 · 14 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@levouh
Copy link
Contributor

levouh commented Jan 18, 2022

Using the following configuration:

require("neo-tree").setup({
  filesystem = {
    window = {
      mappings = {
        ["<CR>"] = "open",
        ["<C-x>"] = "open_split",
        ["<C-v>"] = "open_vsplit",
        [".."] = "navigate_up",
        ["<BS>"] = "close_node",
        ["<C-]>"] = "set_root",
        ["H"] = "toggle_hidden",
        ["I"] = "toggle_gitignore",
        ["R"] = "refresh",
        ["/"] = "filter_as_you_type",
        ["f"] = "filter_on_submit",
        ["<C-l>"] = "clear_filter",
        ["o"] = "add",
        ["dd"] = "delete",
        ["r"] = "rename",
        ["yy"] = "copy_to_clipboard",
        ["x"] = "cut_to_clipboard",
        ["p"] = "paste_from_clipboard",
      },
      position = "float",
      popup = {
        border = {
          top = "",
          style = "rounded",
        },
        size = {
          width = 35,
          height = "100%",
        },
        position = {
          row = "0%",
          col = "0%",
        },
      },
    },
    bind_to_cwd = true,
    filters = {
      show_hidden = true,
      respect_gitignore = false,
    },
    before_render = function(_)
      return
    end,
    components = {
      user_icon = require("user.pack.config.tree.components").user_icon,
    },
    renderers = {
      directory = {
        {
          "user_icon",
          folder_closed = "",
          folder_open = "",
          folder_empty_closed = "",
          folder_empty_open = "",
          padding = " ",
        },
        { "current_filter" },
        { "name" },
        {
          "clipboard",
          highlight = highlights.DIM_TEXT,
        },
      },
    },
  },
})

I observe that when trying to try to expand a node for a directory that contains only hidden files with <CR>, nothing is expanded. The behavior of:

    filters = {
      show_hidden = true,
      respect_gitignore = false,
    },

is strictly related to filters (e.g. /), correct? Or is there a bug there and setting show_hidden = true should actually do what is noted here? As it stands right now, without using the (default) mapping of H, there is no other way to have this directory (containing only hidden files) expand. From what I can tell, this might just be a matter of things being copied over to the current state correctly, but I' not entirely sure how things are intended to behave.

This behavior is shown below:

expand_node_with_only_hidden_files.mp4
@levouh levouh changed the title [Feature] Show hidden files by default [Feature/Bug] Show hidden files by default Jan 18, 2022
@jgottzen
Copy link
Contributor

jgottzen commented Jan 18, 2022

Though it's not documented, and I'm not sure if it is intentional or not, you can achieve this by adding this to your config:

require("neo-tree").setup({
  filesystem = {
    show_hidden = true, -- show hidden files by default
    ...

That is the flag the H toggles.

@cseickel
Copy link
Contributor

@levouh The behavior of the "filters" section of the config actually applies to both browsing and the search mode. It may have been clearer to call the search functionality search instead of also referring to it as filtering. As far as I can see, this is working as intended.

@cseickel cseickel added bug Something isn't working documentation Improvements or additions to documentation labels Jan 18, 2022
@levouh
Copy link
Contributor Author

levouh commented Jan 18, 2022

Though it's not documented, and I'm not sure if it is intentional or not, you can achieve this by adding this to your config:

require("neo-tree").setup({
  filesystem = {
    show_hidden = true, -- show hidden files by default
    ...

That is the flag the H toggles.

Gotcha, this was the issue. I only saw the text show_hidden under the filter table, thanks @jgottzen!

@cseickel I'm happy to submit a mini PR to document this, but would it be easier to do on #60 if the docs method is being reworked?

@cseickel
Copy link
Contributor

Good catch @levouh and @jgottzen! This is the sort of thing I tend to miss because I generally stick with the defaults. The documentation is wrong in this case and I would consider that a bug. Bugs always get fixed first in my book, so I wouldn't hold this up for a larger documentation effort.

PRs are welcome!

@cseickel
Copy link
Contributor

To make things more confused, I see that the filter feature (search) is using the flags within in the filter table as documented. Browsing and filtering should use the same flags, so there is a code change here.

I think the correct thing to do is to make both situations use the flags within the filter table to align with the documentation.

@jgottzen
Copy link
Contributor

@cseickel Ok, I can do a PR for that, if you want?

@cseickel
Copy link
Contributor

That would be great, thanks!

cseickel pushed a commit that referenced this issue Jan 18, 2022
Toggle the state.filters.(show_hidden|respect_gitignore) flags, instead
of setting them on the root state object.
@levouh levouh closed this as completed Jan 18, 2022
@nyngwang
Copy link

nyngwang commented Jan 22, 2022

@cseickel: In case this would be forgotten: the README.md has NOT been updated!

  show_hidden = true,

@cseickel
Copy link
Contributor

@nyngwang I don't think it needs to be. This issue morphed from a request to change the default behavior to a bug fix becuase the code didn't match the existing documentation. The final fix was to update the code to match that documentation but leave the defaults alone.

@nyngwang
Copy link

nyngwang commented Jan 22, 2022

@cseickel: How to show the hidden files by default in the current version? In my current case only If the current open buffer is in a hidden directory then only this folder will be revealed. While I want to see all hidden folders by default, and toggle it to not show them when needed. Should I need to hit H manually every time I open nvim from my terminal?

@cseickel
Copy link
Contributor

cseickel commented Jan 22, 2022

@nyngwang Here is how to change the option and always show hidden files:

require("neo-tree").setup({
  filesystem = {
    filters = {
      show_hidden = true,
      --respect_gitignore = false,
    },
  },
})

@nyngwang
Copy link

nyngwang commented Jan 23, 2022

@cseickel: In case this would be forgotten: the README.md has NOT been updated!

  show_hidden = true,

Maybe you could document this in the README.md? Thanks for your help!

@cseickel
Copy link
Contributor

Sure. I was thinking that it was already there but now I realize it's only in the vim help file. I'll include in the readme for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants