Skip to content

respect_gitignore is not working correctly #78

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

respect_gitignore is not working correctly #78

jgottzen opened this issue Jan 18, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jgottzen
Copy link
Contributor

At least as how I would expect it to.

The plenary.scandir respect_gitignore flag filters out entries in the current scan IFF a .gitignore file is present in the root of the path it scans. The do_scan function in fs_scan.lua scans with a depth of 1, so each time a folder is opened, a new scan is done with the path of that directory, which has the effect that a .gitignore in the root directory isn't picked up.

An example would be

.config/nvim/
|- lua/
   |- packer_compiled.lua
|- .gitignore 

with .gitignore containing lua/packer_compiled.lua; packer_compiled.lua is still visible in the tree.

One solution is to create a gitignore filter in fs_scan.lua and do the filtering there. This can easily be done by just copying the method plenary.scandir uses.

Another one is just scan the whole tree at once and on any refresh and so on, but that might be detrimental when there are a lot of files.

I have implemented the first solution and it works well. Another benefit of doing it that way is that ignored files could be highlighted differently.

@cseickel
Copy link
Contributor

I had noticed some quirky behavior here but I never dug in enough to realize what the issue is.

We definitely don't want to scan the whole tree recursively from the root because lots of people (me included) have some deep folder structures, especially if you go up to the home folder or higher.

I think what I would do is to create and store a gitignore filter on every new scan (without a parent_id) and re-use that for all lazy loaded folders. We also have to make sure that it always searches up the tree and find the right gitignore if this doesn't happen already in plenary.

If you have working fix, feel free to submit a PR or draft PR.

@cseickel cseickel added the bug Something isn't working label Jan 18, 2022
@jgottzen
Copy link
Contributor Author

What I have right now just checks the root directory for a .gitignore file, but as you mentioned this doesn't handle a lot of cases. I'll create a draft PR with what I have right now, and we can discuss how to handle those.

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

No branches or pull requests

2 participants