[FEATURES REQUEST]: take into account of wildignore option and filter FuzzyFiles results with readable.
Closed this issue · 9 comments
I was thinking to a couple of improvements for this tool:
- Take into account of the value of wildignore in the search patterns. Many user may have defined some patterns in their
wildignore, that can include common patterns like for example.git, etc.
option and finding results including what they want to exclude could be a bit annoying. :FuzzyFilesmay show non-readable files. If that is the case, would that be possible to exclude them from the list?
We have a PR working on a similar feature right now. It will be merge soon after testing.
Ok great! I added a note in the PR itself to take into account of 'wildignore'.
Unrelated: what about adding a :FuzzyDir command? That command shall display all the directories starting from pwd the callback after user selection from the popup menu would just... change directory. This would come very handy because when I need to change dir I never remember if foo/ is in ~/foo/, in ~/Documents/foo/ in ~/some/other/weird/location/foo/ and so on.
Unrelated 2: I know that you can list all the files from pwd in a dire with :e **/*<tab> and all the directories with :cd **/*/<tab>. This takes into account the value of wildignore. Could this facts be exploited to improve the search engine of the plugin?
Regarding Unrelated 2 this is possible (and it is blazingly fast).
There is a function called getcompletion(), and you can use it in many ways.
Few examples:
All the files:
:echo getcompletion('**/*', 'file')->filter('v:val != "\/$"')
All the dirs:
:echo getcompletion('**/*', 'dir')
All the coloschemes:
:echo getcompletion('', 'color')
... and much more.
Note that you can directly filter without creating a list first and then filter it, for example:
:echo getcompletion('**/*myfile', 'file')->filter('v:val != "\/$"')
returns the list of files that contains the string myfile that you can directly slam in the popup menu.
You can also choose if the search shall be fuzzy or based on regex, depending on what you put into wildoption option.
A possible way could be that when the popup is visible you set wildoption=fuzzy, call getcompletion({user_input}, {type}) at every keystroke, so the list becomes more and more refined, and then reset wildoption to its previous value once the user hit Enter.
Or, if you don't want fuzzy search, just call getcompletion() at every keystroke, with the first arguments containing what is written in the search box filled by the user.
This could simplify FuzzySeach() function perhaps? And you can re-use the same structure with whatever you want to search (colorscheme, files, directories, ...).
I am just giving some insights because I think this is a very nice plugin. :)
Regarding Unrelated 2 this is possible (and it is blazingly fast).
There is a function calledgetcompletion(), and you can use it in many ways.
Few examples:All the files:
:echo getcompletion('**/*', 'file')->filter('v:val != "\/$"')All the dirs:
:echo getcompletion('**/*', 'dir')All the coloschemes:
:echo getcompletion('', 'color')... and much more.
Note that you can directly filter without creating a list first and then filter it, for example:
:echo getcompletion('**/*myfile', 'file')->filter('v:val != "\/$"')returns the list of files that contains the string
myfilethat you can directly slam in the popup menu.
You can also choose if the search shall be fuzzy or based on regex, depending on what you put intowildoptionoption.A possible way could be that when the popup is visible you
set wildoption=fuzzy, callgetcompletion({user_input}, {type})at every keystroke, so the list becomes more and more refined, and then resetwildoptionto its previous value once the user hitEnter.
Or, if you don't want fuzzy search, just callgetcompletion()at every keystroke, with the first arguments containing what is written in the search box filled by the user.This could simplify
FuzzySeach()function perhaps? And you can re-use the same structure with whatever you want to search (colorscheme, files, directories, ...).I am just giving some insights because I think this is a very nice plugin. :)
Thank you! I will definitely look into these functions!
Just found that using :echo getcompletion('**/*', 'file') may take some time if you are in ~
Anyway, another function worth mentioning is systemlist() to get the output of external programs such as grep or findtsr in a very convenient way - you could perhaps avoid using jobs and related channels and callbacks. But I found other interesting functions that could be useful. I will come later.
Just found that using
:echo getcompletion('**/*', 'file')may take some time if you are in~Anyway, another function worth mentioning is
systemlist()to get the output of external programs such asgreporfindtsrin a very convenient way - you could perhaps avoid using jobs and related channels and callbacks. But I found other interesting functions that could be useful. I will come later.
Yeah, the reason I use job is for its async feature. Any blocking call such as systemlist() may cause vim to not be responsive if you are in a large directory.
That makes sense :)