enricozb / popup.kak

Kakoune popup plugin
21 stars 2 forks source link

trouble setting the fuzzy finder as a user menu #8

Closed AbrA-K closed 3 months ago

AbrA-K commented 3 months ago

I'm pretty new to kakoune and want to use the fuzzy finder in my user menu (in my case: when I'm pressing space f it should be opened). I looked at your demos and tried this: map -docstring "find files" global user f ":popup --title open --kak-script %{edit %opt{popup_output}} -- fzf<ret>"

When trying this, the fzf appears, but does nothing on selecting a file. The debug buffer has this to say: error running command 'evaluate-commands -client 'client0' %§popup-handle-output %§§dismiss§§ %§§0§§ %§§colors/nord.kak§§ %§§§§ %§§edit§§§': 1:1: 'evaluate-commands': 1:1: 'popup-handle-output': 2:3: 'evaluate-commands': 3:1: 'evaluate-commands': 1:1: 'edit': wrong argument count

This doesn't ring a bell to me. I guess the popup_output might be bad? The weird thing: when running this without the user mapping (just typing in the command), it works like advertised. I installed it the recommended way. It seems like I'm getting some kakoune thing really wrong, but I don't know what. I know issues are not for troubleshooting, but this seems to be the best place to ask.

enricozb commented 3 months ago

So in kakoune, expansions (these things %{ .. }) are processed within double quoted strings. So what's happening is that in your invocation of the map command

map -docstring "find files" global user f ":popup --title open --kak-script %{edit %opt{popup_output}} -- fzf<ret>"

the second string argument is processing those expansions, and popup_output is probably empty so this turns into the following command:

map -docstring "find files" global user f ":popup --title open --kak-script edit -- fzf<ret>"

which is of course not what you want. The solution is to use single-quoted strings:

map -docstring "find files" global user f ':popup --title open --kak-script edit -- fzf<ret>'

I'm pretty sure that is the problem.

AbrA-K commented 3 months ago

ooh got it. I also just saw how to escape in double quoted strings (i.e., with %§{§ and not \{) which threw me off.

Thank you! (I think you copied the wrong line and meant:

map -docstring "find files" global user f ':popup --title open --kak-script %{edit %opt{popup_output}} -- fzf<ret>'

)

enricozb commented 3 months ago

No problem! And nicely spotted; try not to have any § in your output as that might mess things up haha :)