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

Silent option doesn't work #85

Open
ghostbuster91 opened this issue Apr 25, 2023 · 2 comments
Open

Silent option doesn't work #85

ghostbuster91 opened this issue Apr 25, 2023 · 2 comments

Comments

@ghostbuster91
Copy link

Hi, thank you for this great plugin.

I notice that the silent option passed to hydra head is not working.
I found #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.

@mdietrich16
Copy link

mdietrich16 commented Nov 13, 2023

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 } },
    },
})

@ghostbuster91
Copy link
Author

@mdietrich16 mamy thanks for posting your solution 💯

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

2 participants