need help for pop-up (is not an issue)
Closed this issue · 11 comments
Hi, I would like to create an input pop-up like your plugin, the form and the input work, but in my case the vim mapping always works on it. For example, if I do <space><space>, which is my nmap on :FuzzyBuffer
, it will write :FuzzyBuffer<cr> in the input pop-up. but with your input pop-up no
how did you manage to get the mapping not to work on the input bars of this plug-in? I've had a look at your source code and I can't figure out where I'm going wrong.
Hi, you can't actually "enter" a Vim popup window, so things like buffer local mappings don't work. You'll need to create a filter function, to which Vim will pass any typed keys while the popup is active, and within that function you can handle the keypresses you want to capture. Have a look at :help popup-filter.
Mimicking a full input prompt with a Vim popup is pretty hariy, hats off to @Donaldttt ! You can see how it works by looking at the PromptFilter function in autoload/fuzzyy/utils/popup.vim. It probably would make a nice plugin on its own tbh (maybe someone else has already done something similar?).
Is your filter function handling space key presses? Seems not, in which case they get passed through and handled as normal.
Something like this should do it…
if key == "\<Space>"
" do something to handle space keypress
return true " tell vim space handled
endif
I tried to add your code in my filter function but it never goes in. it write directly :FuzzyBuffer and skip the space !!!
Are you just missing mapping: false when calling popup_create()? See :help popup-mapping
by the way, I made this feature where you can click to change the cursor position, maybe I could make an MR as a thank you <3
That's cool! But I don't think it would work for Fuzzyy as mouse click is handled by the menu filter, to allow you click a selection to preview and double click to close the popup, sending the line to the close callback (to open file etc.).
Ah, sorry, I forgot that I already added code to check if the mouse clicks are in the menu window before handling them, so it would be simple to just pass on mouse clicks not within that window and have them handled by another popup filter.
I'll update the menu filter to pass on unhandled mouse clicks (it should have always done that tbh). If you'd like to open a PR for mouse click handling in the prompt filter I'd be happy to review, thanks :-)
I have a very similar code for filter input, I can add it easily!
I don't really understand what you've added because it worked quite well with the mouse on it.
I'm going to test this and we'll see :)


