| 1 |
# zellij.nvim |
| 2 |
A lightweight Neovim plugin that integrates Neovim window navigation with [Zellij](https://zellij.dev/). If Neovim can’t move to another window, it automatically falls back to Zellij actions. |
| 3 |
giving you seamless navigation between Neovim splits and Zellij panes/tabs |
| 4 |
## Installing |
| 5 |
### lazyvim |
| 6 |
```lua |
| 7 |
{ |
| 8 |
"y2w8/zellij.nvim", |
| 9 |
event = "VeryLazy", |
| 10 |
opts = {}, -- Important even if empty |
| 11 |
keys = { |
| 12 |
-- Window navigation |
| 13 |
{ "<C-k>", ":ZellijUp<CR>", mode = { "n", "t" }, desc = "Move up", silent = true }, |
| 14 |
{ "<C-j>", ":ZellijDown<CR>", mode = { "n", "t" }, desc = "Move down", silent = true }, |
| 15 |
{ "<C-h>", ":ZellijLeftTab<CR>", mode = { "n", "t" }, desc = "Move left", silent = true }, |
| 16 |
{ "<C-l>", ":ZellijRightTab<CR>", mode = { "n", "t" }, desc = "Move right", silent = true }, |
| 17 |
|
| 18 |
-- Tab actions |
| 19 |
{ "<leader>zt", ":ZellijNewTab<CR>", desc = "New Zellij Tab", silent = true }, |
| 20 |
{ "<leader>zr", ":ZellijRenameTab<CR>", desc = "Rename Zellij Tab", silent = true }, |
| 21 |
{ "<leader>zl", ":ZellijMoveTabLeft<CR>", desc = "Move Tab Left", silent = true }, |
| 22 |
{ "<leader>zL", ":ZellijMoveTabRight<CR>", desc = "Move Tab Right", silent = true }, |
| 23 |
|
| 24 |
-- Pane actions |
| 25 |
{ "<leader>zp", ":ZellijNewPane -d right<CR>", desc = "New Zellij Pane vertical", silent = true }, |
| 26 |
{ "<leader>zP", ":ZellijNewPane -d down<CR>", desc = "New Zellij Pane horizontal", silent = true }, |
| 27 |
{ "<leader>zf", ":ZellijNewPane -f<CR>", desc = "New Zellij Floating Pane", silent = true }, |
| 28 |
{ "<leader>zn", ":ZellijRenamePane<CR>", desc = "Rename Zellij Pane", silent = true }, |
| 29 |
{ "<leader>zu", ":ZellijMovePaneUp<CR>", desc = "Move Pane Up", silent = true }, |
| 30 |
{ "<leader>zd", ":ZellijMovePaneDown<CR>", desc = "Move Pane Down", silent = true }, |
| 31 |
{ "<leader>zh", ":ZellijMovePaneLeft<CR>", desc = "Move Pane Left", silent = true }, |
| 32 |
{ "<leader>zR", ":ZellijMovePaneRight<CR>", desc = "Move Pane Right", silent = true }, |
| 33 |
}, |
| 34 |
} |
| 35 |
``` |
| 36 |
## Commands |
| 37 |
### Navigation |
| 38 |
| Command | Function | Description | |
| 39 |
| --------------- | --------------- | --------------- | |
| 40 |
| `:ZellijUp` | require("zellij").move("up") | Move up | |
| 41 |
| `:ZellijDown` | require("zellij").move("down") | Move down | |
| 42 |
| `:ZellijLeft` | require("zellij").move("left") | Move left | |
| 43 |
| `:ZellijRight` | require("zellij").move("right") | Move right | |
| 44 |
| `:ZellijLeftTab` | require("zellij").move_or_tab("left", false) | Move left or switch tab (zellij tabs) | |
| 45 |
| `:ZellijRightTab` | require("zellij").move_or_tab("right", false) | Move right or switch tab (zellij tabs) | |
| 46 |
| `:ZellijLeftSmart` | require("zellij").move_or_tab("left", true) | Move left or switch tab (nvim tab or zellij tab) | |
| 47 |
| `:ZellijRightSmart` | require("zellij").move_or_tab("right", true) | Move right or switch tab (nvim tab or zellij tab) | |
| 48 |
|
| 49 |
|
| 50 |
### Tab Managment |
| 51 |
> [!TIP] |
| 52 |
> If `name` is not provided, you will be prompted for input. |
| 53 |
> type this in the terminal to see options |
| 54 |
> ```sh |
| 55 |
> zellij action new-tab --help |
| 56 |
> ``` |
| 57 |
|
| 58 |
| Command | Function | Description | |
| 59 |
| --------------- | --------------- | --------------- | |
| 60 |
| `:ZellijNewTab [args?]` | require("zellij").new_tab(args?) | Create new tab | |
| 61 |
| `:ZellijRenameTab [name?]` | require("zellij").rename_tab(name?) | Rename current zellij tab | |
| 62 |
| `:ZellijMoveTabLeft` | require("zellij").move_tab("left") | Move tab left | |
| 63 |
| `:ZellijMoveTabRight` | require("zellij").move_tab("right") | Move tab right | |
| 64 |
|
| 65 |
|
| 66 |
### Pane Managment |
| 67 |
> [!TIP] |
| 68 |
> If `name` is not provided, you will be prompted for input. |
| 69 |
> type this in the terminal to see options |
| 70 |
> ```sh |
| 71 |
> zellij action new-pane --help |
| 72 |
> ``` |
| 73 |
|
| 74 |
| Command | Function | Description | |
| 75 |
| --------------- | --------------- | --------------- | |
| 76 |
| `:ZellijNewPane [args?]` | require("zellij").new_pane(args?) | Create new pane | |
| 77 |
| `:ZellijRenamePane [name?]` | require("zellij").rename_pane(name?) | Rename current zellij pane | |
| 78 |
| `:ZellijMovePaneUp` | require("zellij").move_pane("up") | Move pane up | |
| 79 |
| `:ZellijMovePaneDown` | require("zellij").move_pane("down") | Move pane down | |
| 80 |
| `:ZellijMovePaneLeft` | require("zellij").move_pane("left") | Move pane left | |
| 81 |
| `:ZellijMovePaneRight` | require("zellij").move_pane("right") | Move pane right | |
| 82 |
|
| 83 |
### Custom |
| 84 |
You can run any zellij action using: |
| 85 |
```lua |
| 86 |
require("zellij").zellij_action("toggle-fullscreen") |
| 87 |
``` |
| 88 |
|
| 89 |
> [!TIP] |
| 90 |
> type this in terminal to see possible action |
| 91 |
>```sh |
| 92 |
>zellij action help |
| 93 |
>``` |
| 94 |
|
| 95 |
#### Examples |
| 96 |
##### Toggle fullscreen for the current zellij pane |
| 97 |
```lua |
| 98 |
require("zellij").zellij_action("toggle-fullscreen") |
| 99 |
``` |
| 100 |
|
| 101 |
##### Create a pane while asking for direction and name: |
| 102 |
```lua |
| 103 |
|
| 104 |
vim.keymap.set( |
| 105 |
"n", |
| 106 |
"<leader>zP", |
| 107 |
function() |
| 108 |
local dir = vim.fn.input("Direction (up/down/left/right): ") |
| 109 |
if dir == "" then |
| 110 |
-- default direction |
| 111 |
dir = "right" |
| 112 |
end |
| 113 |
|
| 114 |
local name = vim.fn.input("Pane name: ") |
| 115 |
|
| 116 |
if name == "" then |
| 117 |
-- default name |
| 118 |
name = "Pane" |
| 119 |
end |
| 120 |
|
| 121 |
local args = "-d " .. dir |
| 122 |
if name ~= "" then |
| 123 |
args = args .. " -n " .. name |
| 124 |
end |
| 125 |
|
| 126 |
require("zellij").new_pane({ args = args }) |
| 127 |
end, |
| 128 |
{ desc = "Zellij: New pane (ask direction & name)" } |
| 129 |
) |
| 130 |
|
| 131 |
``` |