hydra.nvim
hydra.nvim copied to clipboard
Silent option doesn't work
Hi, thank you for this great plugin.
I notice that the silent
option passed to hydra head is not working.
I found https://github.com/anuvyklack/hydra.nvim/issues/33 but I am not sure if it can be applied to my use-case.
My main purpose of using hydra is to draw ascii diagrams using https://github.com/jbyuki/venn.nvim So the mappings that I have are like:
heads = {
{ 'H', '<C-v>h:VBox<CR>' },
{ 'J', '<C-v>j:VBox<CR>' },
{ 'K', '<C-v>k:VBox<CR>' },
{ 'L', '<C-v>l:VBox<CR>' },
I my configuration the command line window is displayed in the center of the screen so the inability to set these as silent
makes the experience unpleasant.
I know that you mentioned that it is a tricky problem to solve, but maybe there is another workaround that can be applied in that case?
Also could you provide some explanation what is why it is tricky to have the silent
working.
If you don't have time to fix it, maybe I will be able to help with some guidance.
I stumbled across the same problem and I think I found a solution:
heads = {
{ 'H', '<C-v>h<ESC><CMD>VBox<CR>' },
{ 'J', '<C-v>j<ESC><CMD>VBox<CR>' },
{ 'K', '<C-v>k<ESC><CMD>VBox<CR>' },
{ 'L', '<C-v>l<ESC><CMD>VBox<CR>' },
}
.
Note the replacement of :
with <ESC><CMD>
. <CMD>
alone makes it silent, but only because it does not change the mode, which is needed to end visual mode for setting the necessary marks for VBox
. Hence <ESC>
before, which ends visual mode, triggers setting the marks and then you are free to silently VBox
.
Additionally, I surfaced some builtin capabilities of venn.nvim
:
Hydra({
name = "Draw Diagram",
hint = hint,
config = {
color = "pink",
invoke_on_body = true,
hint = {
border = "rounded",
},
on_enter = function()
vim.o.virtualedit = "all"
end,
},
mode = "n",
body = "<leader>hd",
heads = {
{ "H", "<C-v>h<ESC><CMD>VBox<CR>" },
{ "J", "<C-v>j<ESC><CMD>VBox<CR>" },
{ "K", "<C-v>k<ESC><CMD>VBox<CR>" },
{ "L", "<C-v>l<ESC><CMD>VBox<CR>" },
{ "n", "<ESC><CMD>VBoxO<CR>", { mode = "v" } },
{ "b", "<ESC><CMD>VBoxHO<CR>", { mode = "v" } },
{ "d", "<ESC><CMD>VBoxDO<CR>", { mode = "v" } },
{ "f", "<ESC><CMD>VFill<CR>", { mode = "v" } },
{ "<Esc>", nil, { exit = true } },
},
})
@mdietrich16 mamy thanks for posting your solution :100: