hydra.nvim
hydra.nvim copied to clipboard
Unexpected behavior on pink hydra key overwrite
The title is not a great description of what I am experiencing, so hopefully I can explain better. When setting a pink hydra, such as this lsp hydra
hydra({
name = "LSP Mode",
mode = {"n"},
config = {
color = "pink",
invoke_on_body = true,
hint = {
type = "window",
position = "bottom-right",
border = "rounded",
show_name = true
},
},
hint = [[
LSP
^
Common Actions
- _h_: Show Hover Doc
- _f_: Format Buffer
- _a_: Code Actions
- _s_: Show Definition
^
Help
- _e_: Show Declerations
- _D_: Show Type Definition
- _j_: Show Sig Help
- _o_: Show Implementation
- _r_: Show References
^
_q_/_<Esc>_: Exit Hydra
]],
body = "l",
heads = {
{"s", vim.lsp.buf.definition, {desc = "Show Description", silent = true}},
{"h", vim.lsp.buf.hover, {desc = "Show Hover Doc", silent = true}},
{"o", vim.lsp.buf.implementation, {desc = "Show Implementations", silent = true}},
{"j", vim.lsp.buf.signature_help, {desc = "Show Sig Help", silent = true}},
{"r", vim.lsp.buf.references, {desc = "Show References", silent = true}},
{"f", function() vim.lsp.buf.format({ async = true }) end, {desc = "Format Buffer", silent = true}},
{"a", vim.lsp.buf.code_action, {desc = "Show Code Actions", silent = true}},
{"D", vim.lsp.buf.type_definition, {desc = "Show Type Definition", silent = true}},
{"e", vim.lsp.buf.decleration, {desc = "Show Declerations", silent = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
notice that q is being bound to the quit action. If another plugin is triggered that overrides q for its own purposes after the pink hydra is triggered (an example, vim-visual-multi), it is then impossible to correctly escape the pink hydra. I assume this is because it lost its binding to the q keypress event.
I am aware that I can set a timeout on the hydra, and I am not necessarily saying this is a bug, more of unexpected behavior. Do you have any thoughts on a workaround, or should I stick with
"Dont do that"?
Yes, you are right, hydra and vim-visual-multi are interfere with each other. But I don't know how vim-visual-multi defines its keymapings, and I have no desire to dig (it is written in vimscript), so yes, better not to multiple cursors while you are in the pink hydra state.
@anuvyklack I'm afraid the root of my issue is being lost here. This is not simply a case of don't use vim-visual-multi because they dont work together. They dont work together because vim-visual-multi overwrites the key command that is used for quiting a pink hydra.
IE, if plugin x does the same thing when its triggered (overwrites the function that pressing q calls), then you also cant use plugin x. Any plugin that overwrites the q key will cause issues if used with a pink hydra. I am not necessarily saying this is a problem that needs addressing, but its likely worth calling out somewhere on the readme maybe?
Can you name other such plugins? With vim-visual-multi the problem is that they simultaneously try to remap the same keys.