Skip to content

How to ignore files by pattern (not hide) ? #527

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
soifou opened this issue Sep 17, 2022 · 6 comments
Closed

How to ignore files by pattern (not hide) ? #527

soifou opened this issue Sep 17, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@soifou
Copy link

soifou commented Sep 17, 2022

Recently, a PR from null-ls changes the path where are stored the temp files of some diagnostics/formatters.
For example on linux, there were stored to $XDG_RUNTIME_DIR (or /tmp as fallback). Now there are stored to the current buffer dir.

This has some visuals annoying consequences with my setup when I'm working with the filesystem opened . My first thought was to add a pattern in option filtered_items.hide_by_pattern but this only seems to hide them (as the name suggests).

Below the visual annoyances in action (first hidden, then displayed).

2022-09-17_00-53-21.mp4

I'd like Neotree completely forget about theses files. Is something going wrong with my settings or this is not yet implemented (something like never_show_by_pattern)?

Thanks in advance for your help!

     require("neo-tree").setup({
          close_floats_on_escape_key = false,
          use_popups_for_input = false,
          popup_border_style = my_borders,
          enable_diagnostics = false,
          enable_modified_markers = true,
          -- Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false.
          enable_refresh_on_write = false,
          default_component_configs = { ⋯
          },
          window = { ⋯
          },
          filesystem = {
              async_directory_scan = "auto",
              follow_current_file = true,
              use_libuv_file_watcher = true,
              -- These filters are applied to both browsing and searching
              filtered_items = {
                  visible = false,
                  hide_dotfiles = true,
                  hide_gitignored = true,
                  hide_by_pattern = { "_null-ls_*" },
                  never_show = { ".git" },
              },
              commands = { ⋯
              },
              components = { ⋯
              },
          },
      })
@cseickel
Copy link
Contributor

cseickel commented Sep 18, 2022

@soifou I have the first of a two part fix done, which is to make the file watchers ignore the null-ls temp files so the tree doesn't keep refreshing. Can you switch to the main branch and try it out?

I also intend to add a never_show_by_pattern option, but I think the file watcher change is all you really need for this specific case.

@soifou
Copy link
Author

soifou commented Sep 18, 2022

Unfortunately not.

The next related PR has just been merged, so the pattern matching you set is incorrect, it should be ^%.null[-]ls_.+ instead.

By changing to this pattern, the watch_folder skips these temp files and does not fire unnecessary event.
But the git tree keeps refreshing with "?" signs (the watch_git_index does not catch any of theses temp files)
As well as the hidden count keeps... counting.

I also intend to add a never_show_by_pattern option, but I think the file watcher change is all you really need for this specific case.

That's good to hear because the thing is what if they change again the pattern? This needs to be reflected here.

@cseickel cseickel added the enhancement New feature or request label Sep 18, 2022
@cseickel
Copy link
Contributor

The never_show_by_pattern option has been added in the latest commit on main.

I also made it so that any file that would be captured by never_show or never_show_by_pattern will also be ignored in file watcher events.

I believe this is the pattern you want for this situation:

    require("neo-tree").setup({
      filesystem = {
        filtered_items = {
          never_show_by_pattern = { -- uses glob style patterns
            ".null-ls_*",
          },
        },
      }
    })

@soifou
Copy link
Author

soifou commented Sep 18, 2022

Yes never_show_by_pattern is working as intended! Thanks a lot.

One (minor) issue though but this is not really on your side.

Since a temp file is created for a few sec when I'm doing some operations on a buffer, Neotree git watch index detects it and the parent directories reflect this by showing the question mark sign. That could lead to some misunderstanding about the current state. Question marks disappears if I toggle the tree or save again the buffer or spawn a new term on the project root dir, etc.

I could add an entry to my .gitignore and this will solve the problem but maybe you have a better idea how you could handle it in Neotree?

@cseickel
Copy link
Contributor

I could add an entry to my .gitignore and this will solve the problem but maybe you have a better idea how you could handle it in Neotree?

I actually think that is the best way to handle this. That will also cover the situation where a temp file is not cleaned up by null-ls.

@soifou
Copy link
Author

soifou commented Sep 18, 2022

Ok then feel free to close this issue! And by the way, null-ls will handle the cleanup on its side 😉

Thanks again for your support!

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

2 participants