Skip to content
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

new nvim-tree.filters to point to custom files with regexes with ignore patterns #2367

Open
rafaeldelboni opened this issue Aug 12, 2023 · 7 comments
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated QOL Quality Of Life Improvement

Comments

@rafaeldelboni
Copy link

A new nvim-tree.filters that would behave exactly as nvim-tree.filters.git_ignored but we could set custom file names like .ignored.

There are some cases we don't want to git ignore some files, but we want to hide from tools like this or ripgrep, ripgrep has some extra files where you can define your ignored regex patterns like .ignore or .rgignore using
Filtering options.

Something like this:

    *nvim-tree.filters.custom_file_ignored* 
    Ignore using custom files that behave like `.gitignore`, but with a different name like `.ignored`. 
    Toggle via |nvim-tree-api.tree.toggle_custom_file_ignored_filter()|, default `G`
      Type: `{string}`, Default: `{}`
@alex-courtis
Copy link
Member

alex-courtis commented Aug 13, 2023

It seems that you'd like :help nvim-tree.filters.custom except reading from a file, using "regular" regexes instead of vim regexes.

This one's a bit tricky; we don't have a .gitignore parser like ripgrep and the_silver_searcher do, instead git does the ignoring for us. I did look at adding a .gitignore parser however it's not simple: gitignore.rs

I'm open to the idea; my .custom is a bit messy.

Do you know the syntax of .ignore files? Neither ripgrep nor the_silver_searcher specify it. Using a "standard" ignore file is preferable to, say, a .nvimtreeignore file.

@alex-courtis alex-courtis added awaiting feedback QOL Quality Of Life Improvement labels Aug 13, 2023
@rafaeldelboni
Copy link
Author

For ripgrep I use the .ignore with the .gitignore sintaxe, one example that is working fine for me:
https://github.com/rafaeldelboni/cajus-nfnl/blob/main/.ignore

@rafaeldelboni
Copy link
Author

I found this doc about the .ignore on ripgrep
https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#automatic-filtering

@alex-courtis
Copy link
Member

I found this doc about the .ignore on ripgrep https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#automatic-filtering

That looks good. I'm still not clear on exactly what the .ignore glob syntax is. Is it the same as .gitignore syntax? It looks like it might be: https://github.com/BurntSushi/ripgrep/blob/009dda1488ac6a01725b3e49ec9b81a1edf8036d/crates/ignore/src/dir.rs

As stated above, we'd need some sort of glob parser. nvim-treesitter appears to have a .gitignore parser: https://github.com/nvim-treesitter/nvim-treesitter/blob/4e35ae6f71f5b734ffd876cf8661630cea3a26ae/lua/nvim-treesitter/parsers.lua#L549

I'm open to adding treesitter or tree-sitter-gitignore as an optional dependency to support .ignore files. Are you willing to attempt this addition?

@rafaeldelboni
Copy link
Author

You mean https://github.com/shunsambongi/tree-sitter-gitignore ?
It looks like a C project is possible to add this as dependency?

I have no experience with lua, but I can try to do the addition :)

@alex-courtis
Copy link
Member

It looks like a C project is possible to add this as dependency?

I see. It seems to install and run OK with packer. It doesn't look like there are any actual binaries; the c files just look like tests.

Let's try it and see how it looks!

@alex-courtis alex-courtis added PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated and removed awaiting feedback labels Aug 20, 2023
@alex-courtis
Copy link
Member

As per #2438 we can add .gitignore and friends to watchers ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated QOL Quality Of Life Improvement
Projects
None yet
Development

No branches or pull requests

2 participants