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

feat: add custom ignore dir/files. #32

Merged
merged 9 commits into from
Aug 24, 2024
Merged

Conversation

okayno14
Copy link
Contributor

Deafault config contains in autoload/ignore_tree/ignore_tree.vim. And can be customized by editing g:fuzzyy_custom_ignore:
Example:

   let g:fuzzyy_custom_ignore = {
       \ 'dir': ['.git', '.hg', '.svn', '.rebar', '.eunit'],
       \ 'file': ['*.beam', '*.so', '*.exe', '*.dll', '*.dump', '*.core', '*.swn', '*.swp'],
  \ }

@okayno14
Copy link
Contributor Author

@Donaldttt when can you check it?

@Donaldttt
Copy link
Owner

Hi Thank you for the pull request. I was in vacation the last week and I will review it this couple days.

@okayno14
Copy link
Contributor Author

Hi Thank you for the pull request. I was in vacation the last week and I will review it this couple days.

Sure, no problem. I just thought, that github didn't sent notification.

@Donaldttt
Copy link
Owner

Thanks a lot for this PR. I had the though about adding this feature long time ago but never had the determination.

I would like to make some changes to this PR.

  1. I merge all the builders into a single file since it is only a small feature.
  2. I change the name of the option for adding custome ignore.
  3. I will probably remove the test since It seem to have a bug that cause it to fail in Windows OS. And it seem to be a bug from vim itself.
vim9script
def Case1(): void
    echom [has("win32"), has("win64")]
    echom [1, 0]
    echom [has("win32") || has("win64")]
    echom [1 || 0]
    if has("win32") || has("win64")
        echo "skipped, wrong OS:windows"
        return
    endif
enddef
Case1()

The above code will have output like this and I can't figure out why:

[1, 0]
[1, 0]
[false]
[true]

@okayno14
Copy link
Contributor Author

Thanks a lot for this PR. I had the though about adding this feature long time ago but never had the determination.

I would like to make some changes to this PR.

  1. I merge all the builders into a single file since it is only a small feature.
  2. I change the name of the option for adding custome ignore.
  3. I will probably remove the test since It seem to have a bug that cause it to fail in Windows OS. And it seem to be a bug from vim itself.
vim9script
def Case1(): void
    echom [has("win32"), has("win64")]
    echom [1, 0]
    echom [has("win32") || has("win64")]
    echom [1 || 0]
    if has("win32") || has("win64")
        echo "skipped, wrong OS:windows"
        return
    endif
enddef
Case1()

The above code will have output like this and I can't figure out why:

[1, 0]
[1, 0]
[false]
[true]

Good!!

About tests: interesting bug, i never encountered it, but if you have it, that other users also can. Then it's ok to be removed.

@Donaldttt Donaldttt merged commit be535c8 into Donaldttt:vim9 Aug 24, 2024
@ubaldot
Copy link
Contributor

ubaldot commented Aug 24, 2024

Nice! Perhaps the search engine should also consider what is specified in the 'wildignore' option. That is, if a user has set wildignore+=**/foo/, then seeing displaying some/folder/foo/somefile.txt in the results would be weird.

@okayno14
Copy link
Contributor Author

Nice! Perhaps the search engine should also consider what is specified in the 'wildignore' option. That is, if a user has set wildignore+=**/foo/, then seeing displaying some/folder/foo/somefile.txt in the results would be weird.

Sounds like a good idea, that plugin feature must integrate more with standard vim env.
But now, i'm not sure, that's all supported search tools can support fully this wildpatterns.
Need to do little research about that.

@ubaldot
Copy link
Contributor

ubaldot commented Aug 24, 2024

Need to do little research about that.

If you use grep, perhaps it is enough to add each element of wildignore option to --exclude and --exclude-dir flag of grep.

For example, as a basic idea one could define var wildignore_paths = split(&wildignore, ',') and add each element of the resulting list into a--exclude or --exclude-dir flag.

The only problem is that wildignore consider ignore patterns, it does not really differentiate between files and paths, whereas it seems that grep wants separated files and folders. One way could be that whatever an element in wildignore has a trailing /*, then it is considered as a directory, or a file otherwise (not sure how robust it is). That is:

  • Patterns ending with /*: These patterns will match directories. For example, the pattern **cache**/* exclude all the files included in folders and subfolders that contains the string cache in their name, thus excluding the whole directories that contains cache in their name.
  • Patterns without a trailing /*: These patterns will match files.

Alternatively, perhaps one could also think to redesign g:fuzzyy_custom_ignore such that it only consider patterns instead of differentiating between paths and files. I think in .gitignore you specify ignore patterns without differentiating, if I am not wrong. What do you think? :)

@okayno14
Copy link
Contributor Author

  • Patterns ending with /*: These patterns will match directories. For example, the pattern **cache**/* exclude all the files included in folders and subfolders that contains the string cache in their name, thus excluding the whole directories that contains cache in their name.
  • Patterns without a trailing /*: These patterns will match files.

Good idea, it may be work.

Alternatively, perhaps one could also think to redesign g:fuzzyy_custom_ignore such that it only consider patterns instead of differentiating between paths and files. I think in .gitignore you specify ignore patterns without differentiating, if I am not wrong. What do you think? :)

The idea about splitting dir list and file was for ability to easily apply
separate logic for files and dirs, cause 'find' needed it, and i thout, that
others commands also behave similarly.

Anyway, we can make 1 list and differntiate files and dirs by '/' or '' at the
end of expression.

@ubaldot
Copy link
Contributor

ubaldot commented Aug 27, 2024

I opened a PR yesterday:)

@ubaldot
Copy link
Contributor

ubaldot commented Aug 27, 2024

Anyway, we can make 1 list and differntiate files and dirs by '/' or '' at the
end of expression.

This is not possible because of the way wildignore works (you can try yourself :) ).

The idea about splitting dir list and file was for ability to easily apply
separate logic for files and dirs, cause 'find' needed it, and i thout, that
others commands also behave similarly.

I also like this approach of differentiating. You can take a look at #42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants