RishabhRD / nvim-cheat.sh

cheat.sh integration for neovim in elegant way
151 stars 8 forks source link

fuzzy searching of symbols if prompt query is insufficient #8

Closed RishabhRD closed 3 years ago

RishabhRD commented 3 years ago

As discussed in #7, if the prompt text is insufficient for making a query like empty prompt text or prompt text that only includes a language like cpp then instead of aborting with a message of requires query, open a fuzzy finder for users to choose from available choices.

the selection of choice would make a new prompt with the initial text being the selected choice from the fuzzy list

Because this feature can be used independently, this pull request also exports 2 commands:

As the name suggests, this would open a list of symbols available with cheat.sh

RishabhRD commented 3 years ago

@tami5 I have opened the PR, with the initial implementation. It is rough work for now and many cases are still not covered. (Like users provide only whitespaces, etc). But this should show the rough idea of PR.

I hope the file changed in PR would explain the basic working of popfix also. This is mostly opts and callback mechanism. If something is not clear, please ask because code can be a little messy :sweat_smile: This should help you in getting involved with the code directly.

Please update popfix plugin also, I just added a job completion notification a few hours back to it.

RishabhRD commented 3 years ago

@tami5 I have done some modifications for detecting the conditions of insufficient prompt text. Previously, if we used to query a command like find then it would show Please provide a query However, this means we can't search for linux commands using the pluign.

Now, these conditions are handled properly and we get results in result buffer.

Also, some edge cases like if user provide only whitespace are not handled properly.

RishabhRD commented 3 years ago

@tami5 I have done some modifications for detecting the conditions of insufficient prompt text. Previously, if we used to query a command like find then it would show Please provide a query. This means we can't search for Linux commands using the plugin.

Now, these conditions are handled properly and we get results in the result buffer.

Also, it handles some edge cases like only whitespace in prompt.

kkharji commented 3 years ago

😍 Amazing i'm going to to test and review in few hours . Well done

kkharji commented 3 years ago

I just did some quick testing, the prompt open even with no items to select from, also sometime it breaks and the layout stays in the screen, forcing me to leave the vim instance.

CheatList seem to do what is expected. but as soon I hit enter on the item, here you go with the damn prompts again :D.

RishabhRD commented 3 years ago

Hi! @tami5 Glad! it helps for telescope extensions. :smiley: You mentioned:

the prompt open even with no items to select from

Can you share a gif or something for this please? Because maybe list would not be available initially due to network issue or something and it would take a second or so to load. Because I am not facing it. A gif or something would help a lot here. If network issue, I am working on it (#5)

sometime it breaks and the layout stays on the screen, forcing me to leave the vim instance

I got a little lazy here. I should have wrapped the function in vim.schedule so that every UI event executes properly. I would push it in a while.

CheatList seem to do what is expected. but as soon I hit enter on the item, here you go with the damn prompts again

Actually, It was intentional behavior. It must be opening prompt again with initial prompt text as what was selected from fuzzy search (If not then it's a serious bug:sweat_smile:). My idea behind this was, users may want to edit the selected choice before getting results. Is this behavior too distracting from user point of view?

kkharji commented 3 years ago

Here is a preview of what I'm experimenting, sadly it didn't capture carching but it capture some undesired behaviors https://asciinema.org/a/bzSwMChtd768gz47cWfJRmJMo

Is this behavior too distracting from user point of view?

I think so, also if you really want to go vim way and what vim user expect is to add completion and use the command line as solo prompt, other wise for more selection then fuzzy.

Its really easy to do I think there is an example for command args completion. so the user will end up typing Cheat list to get everything in cheat, then another tab to get stuff for the first argument.

This I think by far the best experience to have then the prompt.

Good luck