Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slimv with which-key #108

Open
Kingsy opened this issue Mar 5, 2021 · 8 comments
Open

Slimv with which-key #108

Kingsy opened this issue Mar 5, 2021 · 8 comments

Comments

@Kingsy
Copy link

Kingsy commented Mar 5, 2021

Hi,

Have you had experience using this plugin with which-key? It seems to have a lot of default key bindings which pollute the which-key leader and local leader menus.
Is it possible to disable all key bindings somehow so I can create my own menu map with which-key?

If so is there a list of commands somewhere I can use when rebinding the key bindings? At the moment they appear as so in which-key

→ call PareditMoveRight()|silent! call repeat#set("<leader>>")

I am not sure 'call PareditMoveRight()|silent! call repeat#set("<leader>>")' would work as the key binding would it?
Just want to clarify this, cant find much info on it.

Thanks

@kovisoft
Copy link
Owner

kovisoft commented Mar 6, 2021

Sorry, but this is the first time I heard about which-key, and I don't quite understand this issue. Could you please describe it in more detail?

Slimv has the g:slimv_keybindings option, values 1 and 2 define two built-in mappings, any other value means no mapping is defined by slimv, so you can create your own.

Unfortunately there is no similar option for paredit at the moment.

@Kingsy
Copy link
Author

Kingsy commented Mar 8, 2021

which-key is a leader guide that allows the creating of a menu system for the leader and local leader key bindings
https://github.com/liuchengxu/vim-which-key

It allows creating a map as so, which gives the ability to hide groups of functionality behind a single binding. Then use a further level of bindings after the initial is pressed. l in this case is "lsp" which as you can imagine contains alot of keybindings, but in the screenshot below appears as a single "l" group

let g:which_key_map.l = {
\ 'name' : '+lsp' ,
\ 'd' : ['Lua("vim.lsp.buf.definition()")' , 'definition'],
.....
\ }

However given the amount of keybindings enabled by Paredit and slimv by default it pollutes the menu somewhat. In this case the steps would be to disable the keybindings for the plugin and build them again using an object just like above.
I have attached a couple of screenshots to show how with slimv enabled the which-key leader menu is less readable.

So two questions.

  1. How can disable all keybindings for slimv and Paredit, you mentions its possible with slimv but not Paredit, is there any other way I can achieve this?
  2. Once disabled how can I get the commands for each keybinding. They appear in which-key as so, call PareditMoveRight()|silent! call repeat#set(">") but I am not sure how that and the others translate into vim commands?

Thanks

slimv_000
normal

@kovisoft
Copy link
Owner

kovisoft commented Mar 9, 2021

Thank you for the explanation. When you say you want to disable all keybindings, do you mean only the bindings starting with <leader> or do you mean all bindings, including such as (, ), Enter, Backspace, Del, ", x, s, d, c, p, etc?

Regarding your questions:

  1. I can add an option to Paredit for disabling the mappings, similar to the one already in Slimv.
  2. If you don't use the repeat plugin then you can ignore the part staring with | and followed by the repeat#set stuff, but keeping the <CR> at the end. So in case of :<C-U>call PareditMoveRight()|silent! call repeat#set(",>")<CR> you can use :<C-U>call PareditMoveRight()<CR> (but I think it's easier just to leave the command as is). The whole vim map command is then: nnoremap <buffer> <silent> <leader>> :<C-U>call PareditMoveRight()<CR>. The | is just a command separator, and the followed repeat#set command is either executed (if the plugin is installed) or just silently isn't doing anything.

@Kingsy
Copy link
Author

Kingsy commented Mar 23, 2021

Thankyou for this.

I am tempted to leave it all as is. It would just be great to get them named nicely in the which-key config so its all easier to read.

Should I leave this open and we can close it when you have had time to add the option you spoke about to paredit?

Thanks so much.

@kovisoft
Copy link
Owner

kovisoft commented Apr 5, 2021

I added two new options: g:paredit_map_func and g:paredit_unmap_func in commit de657dd . You can define your own custom keybinding mapping and unmapping functions here. The mapping function is called at buffer initialization and upon switching paredit mode on again (via ,(). The unmapping function is called upon switching paredit mode off (also via ,().

Example usage:

let g:paredit_map_func='MyPareditMapKeys'
let g:paredit_unmap_func='MyPareditUnmapKeys'

function! MyPareditMapKeys()
    execute 'nnoremap <buffer> <silent> ' . g:paredit_leader.'J  :<C-U>call PareditJoin()<CR>'
endfunction

function! MyPareditUnmapKeys()
    silent! execute 'unmap  <buffer> ' . g:paredit_leader . 'J'
endfunction

By default functions PareditMapKeys and PareditUnmapKeys are used, you can find the assigned mappings in these functions. Please check if these options solve this issue.

@remexre
Copy link

remexre commented May 8, 2024

Maybe this is worth a separate ticket, but which-key.nvim appears to also have issues, even when explicitly calling :call SlimvEvalDefun() -- instead of doing the thing, it puts me into insert mode on the following line. I haven't had time to dig deeper, but does this seem directly related to the issue with vim-which-key or worth making a separate ticket for?

@kovisoft
Copy link
Owner

kovisoft commented May 8, 2024

TBH I still don't know much about which-key (and, as a matter of fact, about nvim), but as I understand it handles keybindings, so if you experience problems also when directly entering the command (without using any keybinding), then this issue does not seem to be related with which-key.

@remexre
Copy link

remexre commented Aug 30, 2024

@Kingsy can you see if #140 resolves this as well? (I strongly suspect it does; if not, can you send the output of :map v?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants