AckslD / nvim-neoclip.lua

Clipboard manager neovim plugin with telescope integration
944 stars 20 forks source link

Telescope which_key shows <anonymous> instead of action #64

Closed drybalka closed 2 years ago

drybalka commented 2 years ago

Telescope has a useful feature to show mappings on <?> or (internally called telescope.actions.which_key). However, for neoclip it shows instead of actions (for example, paste or paste_previous) and prints an error "No name available for anonymous functions". It would be great if this worked as intended.

AckslD commented 2 years ago

Sounds good @drybalka! Do you know how to set those names or where that is documented :)

drybalka commented 2 years ago

I made a small PR that should fix it. Basically the idea was to first create a local named function and then return it. You can rename them to your liking, I stuck with names from the config.

AckslD commented 2 years ago

Oh it uses the name of the function? That's a bit weird, do you know if it's possible to provide an explicit separate name for it instead? I think the code is a bit cleaner without assigning the functions to variables.

Thanks for the PR!

drybalka commented 2 years ago

I couldn't find how to provide a function with name otherwise, sorry. Here is where estimation happens in telescope, maybe you'll have an idea how to do it.

AckslD commented 2 years ago

Thanks for the reference @drybalka! Looking around a bit more in the source code it seems you can provide a table instead where the first entry is a description which seems to wok. Let me know if #67 does indeed work for you.

drybalka commented 2 years ago

Works for me, and the code is indeed cleaner this way =) Thanks! You can close my PR then, I think.

AckslD commented 2 years ago

Thanks for checking, I made another change cause I realised that the keybinds were actually not working. Instead I made them now a metatable which seems to work for both the action and the names.