cheatsheet.nvim icon indicating copy to clipboard operation
cheatsheet.nvim copied to clipboard

Integration with folke/whichkey.nvim?

Open macintacos opened this issue 3 years ago • 6 comments

I'm getting my mappings set up in https://github.com/folke/which-key.nvim and was just thinking how nice it'd be if this integrated with which-key.nvim so that I could define my keymaps there and be able to search the labels of the keybindings that are given there with this tool. If I use cheatesheet.nvim, I'd basically need to be typing out those descriptions twice, and I'd love it if I could save myself the hassle 🙂

I understand that this kinda goes against the premise, however it feels like a fit that would "make sense" and be an awesome convenience for the folks who've already spent a bunch of time getting their which-key configs set up.

macintacos avatar Jun 06 '21 23:06 macintacos

I was thinking about this a few days back and it slipped through my mind :P. As you said it'll make for a smoother experience overall. Thank you for opening an issue !

sudormrfbin avatar Jun 07 '21 02:06 sudormrfbin

For reference, this is the way to do it - https://github.com/folke/which-key.nvim/issues/96#issuecomment-863162064. I'll get around to it soon (PRs also welcome :P)

sudormrfbin avatar Jul 05 '21 17:07 sudormrfbin

@sudormrfbin Is there any existing (or planned) mechanism for adding cheatsheet entries from lua?

My thought being something like: require('cheatsheet.nvim').add_cheat(description, cheatcode) to just add it to the existing table of entries

Corey-Keller avatar Aug 11 '21 19:08 Corey-Keller

@Corey-Keller There is no existing way to do it, but it shouldn't be too hard to add. Can you share a use case for it though ? Do you want to programmatically set them on startup or something similar ?

sudormrfbin avatar Aug 13 '21 15:08 sudormrfbin

@Corey-Keller There is no existing way to do it, but it shouldn't be too hard to add. Can you share a use case for it though ? Do you want to programmatically set them on startup or something similar ?

Pretty much yeah. This issue itself is a pretty good use case actually. Get all the mappings from which-key.nvim, and then run through them to add to cheatsheet.

Corey-Keller avatar Aug 13 '21 16:08 Corey-Keller

@Corey-Keller I've added add_cheat in 5be58ae:

https://github.com/sudormrfbin/cheatsheet.nvim/blob/5be58aeabdf65034c9636e3c6f4f43de5ea93932/lua/cheatsheet/init.lua#L58-L64

sudormrfbin avatar Aug 16 '21 06:08 sudormrfbin