folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.4k stars 176 forks source link

How to map with Plug? #38

Closed thepenguinthatwants closed 3 years ago

thepenguinthatwants commented 3 years ago

Hi Folke, Using which-key plugin that has being converted to lua was insane improvement to quick and slickness.

There is something I haven't gotten to work with this plugin.

let g:which_key_map['z'] = [ '<Plug>(zoom-toggle)' , 'zoom' ]

This worked with the old plugin

When I tried to convert into lua , I haven't figured out why it doesnt seem to work at all.

vim.api.nvim_set_keymap("n", "<leader>z", "<Plug>(zoom-toggle)", {noremap = true, silent = true})

Any clue what I might be missing with this syntax?

folke commented 3 years ago

noremap should be false, since what you want to achieve is literally remapping the <plug> key to another command ;)

folke commented 3 years ago

You can also pass the plug to register to let WhichKey handle it. We automatically set noremap=false for <Plug> commands.

folke commented 3 years ago

something like:

wk.register({
  ["<leader>z"] = { '<Plug>(zoom-toggle)' , 'zoom' }
})

or

wk.register({
  z = { '<Plug>(zoom-toggle)' , 'zoom' }
}, {prefix = "<leader>")
thepenguinthatwants commented 3 years ago

:D Thanks, damn I was dull for not noticing that its remapping.

If I am not wrong the improvement with registers is actually giving ability to map without using leader key and have a cheatsheet type of help.

Thats insanely cool.

Like I mapped to leader as I had now clue how to get the

<C-w>z to work.

wk.register({
  ["<C-w>z"] = { '<Plug>(zoom-toggle)' , 'zoom' }
})

This worked perfectly! The improvement is insane!

folke commented 3 years ago

Glad you like it 😄