shoukoo / dotfiles

my dotfiles for my personal machine.
MIT License
4 stars 0 forks source link

Zellij <3 neovim #3

Closed rafaelpirolla closed 2 days ago

rafaelpirolla commented 2 days ago

There's a new option on zellij now: default_mode "locked"

https://zellij.dev/news/colliding-keybinds-plugin-manager/

Could be of your interest.

rafaelpirolla commented 2 days ago

Anyhow, startpage.com sent me to your blog and I've decided to comment it out here some things I've discovered. It's not perfect but I believe it's what's achievable at the moment.

Current issue:

I'm using arrows instead of hjkl and Alt as the global modifier – you only need to change the zellij binds to use hjkl. In the zellij shared_among probably most modes (you can choose), you include this:

bind "Alt left" {
    MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
        name "move_focus_or_tab";
        payload "left";

        // Plugin Configuration
        move_mod "ctrl"; // Optional, should be added on every command if you want to use it
    };
}

bind "Alt down" {
    MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
        name "move_focus";
        payload "down";

        move_mod "ctrl";
    };
}

bind "Alt up" {
    MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
        name "move_focus";
        payload "up";

        move_mod "ctrl";
    };
}

bind "Alt right" {
    MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
        name "move_focus_or_tab";
        payload "right";

        move_mod "ctrl";
    };
}

bind "Ctrl left" {
  MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
    name "resize";
    payload "left";

    resize_mod "alt"; // Optional, should be added on every command if you want to use it
  };
}

bind "Ctrl down" {
  MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
    name "resize";
    payload "down";

    resize_mod "alt";
  };
}

bind "Ctrl up" {
  MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
    name "resize";
    payload "up";

    resize_mod "alt";
  };
}

bind "Ctrl right" {
  MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
    name "resize";
    payload "right";

    resize_mod "alt";
  };
}

And on neovim side:

return {
  {
    "https://github.com/swaits/zellij-nav.nvim",
    lazy = true,
    event = "VeryLazy",
    keys = {
      { "<c-Left>", "<cmd>ZellijNavigateLeftTab<cr>",  { silent = true, desc = "navigate left or tab"  } },
      { "<c-Down>", "<cmd>ZellijNavigateDown<cr>",  { silent = true, desc = "navigate down"  } },
      { "<c-Up>", "<cmd>ZellijNavigateUp<cr>",    { silent = true, desc = "navigate up"    } },
      { "<c-Right>", "<cmd>ZellijNavigateRightTab<cr>", { silent = true, desc = "navigate right or tab" } },

      { "<c-h>", "<cmd>ZellijNavigateLeftTab<cr>",  { silent = true, desc = "navigate left or tab"  } },
      { "<c-j>", "<cmd>ZellijNavigateDown<cr>",  { silent = true, desc = "navigate down"  } },
      { "<c-k>", "<cmd>ZellijNavigateUp<cr>",    { silent = true, desc = "navigate up"    } },
      { "<c-l>", "<cmd>ZellijNavigateRightTab<cr>", { silent = true, desc = "navigate right or tab" } },

      { "<a-Left>", "<cmd>vertical resize +10<cr>",  { silent = true, desc = "navigate left or tab"  } },
      { "<a-Down>", "<cmd>resize -10<cr>",  { silent = true, desc = "navigate down"  } },
      { "<a-Up>", "<cmd>resize +10<cr>",    { silent = true, desc = "navigate up"    } },
      { "<a-Right>", "<cmd>vertical resize -10<cr>", { silent = true, desc = "navigate right or tab" } },

      { "<a-h>", "<cmd>vertical resize +10<cr>",  { silent = true, desc = "navigate left or tab"  } },
      { "<a-j>", "<cmd>resize -10<cr>",  { silent = true, desc = "navigate down"  } },
      { "<a-k>", "<cmd>resize +10<cr>",    { silent = true, desc = "navigate up"    } },
      { "<a-l>", "<cmd>vertical resize -10<cr>", { silent = true, desc = "navigate right or tab" } },
    },
    opts = {},
  }
}

This one was really complicated for me to configure because it took me a while to understand that, no matter what, the plugin is build to send + hjkl.

Here's the thread where I found most of the info: https://github.com/zellij-org/zellij/issues/967

swaits commented 1 day ago

Note that zellij-nav.nvim is mirrored on Github now if you prefer to pull it form there instead of from Sourcehut. https://github.com/swaits/zellij-nav.nvim

rafaelpirolla commented 1 day ago

Thanks, I'll fix the post also. Did some modifications to it.