index : neolij.nvim
Seamless Neovim/Zellij integration with built-in navigation, pane/tab management, and Lua scripting.
about summary refs log tree commit diff
neolij.nvim / README.md
-rw-r--r-- blob 7eb5c0005129a7b384c22fe32a162698afa977dd 8529 bytes (plain)
1
# Neolij.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
5
## Demo
6
<img width="782" height="650" alt="demo" src="https://github.com/user-attachments/assets/f7159320-d5bc-43bb-a0ca-a2e15077d5ba" />
7
8
## Installing
9
### lazyvim
10
```lua
11
{
12
   "y2w8/neolij.nvim",
13
    event = "VeryLazy",
14
    opts = {}, -- Important even if empty
15
    keys = {
16
    -- Window navigation
17
    { "<C-k>", ":NeolijUp<CR>", mode = { "n", "t" }, desc = "Move up", silent = true  },
18
    { "<C-j>", ":NeolijDown<CR>", mode = { "n", "t" }, desc = "Move down", silent = true  },
19
    { "<C-h>", ":NeolijLeftTab<CR>", mode = { "n", "t" }, desc = "Move left", silent = true  },
20
    { "<C-l>", ":NeolijRightTab<CR>", mode = { "n", "t" }, desc = "Move right", silent = true  },
21
22
    -- Tab actions
23
    { "<leader>zt", ":NeolijNewTab<CR>", desc = "New Zellij Tab", silent = true  },
24
    { "<leader>zr", ":NeolijRenameTab<CR>", desc = "Rename Zellij Tab", silent = true  },
25
    { "<leader>zl", ":NeolijMoveTabLeft<CR>", desc = "Move Tab Left", silent = true  },
26
    { "<leader>zL", ":NeolijMoveTabRight<CR>", desc = "Move Tab Right", silent = true  },
27
28
    -- Pane actions
29
    { "<leader>zp", ":NeolijNewPane -d right<CR>", desc = "New Zellij Pane vertical", silent = true  },
30
    { "<leader>zP", ":NeolijNewPane -d down<CR>", desc = "New Zellij Pane horizontal", silent = true  },
31
    { "<leader>zf", ":NeolijNewPane -f<CR>", desc = "New Zellij Floating Pane", silent = true  },
32
    { "<leader>zn", ":NeolijRenamePane<CR>", desc = "Rename Zellij Pane", silent = true  },
33
    { "<leader>zu", ":NeolijMovePaneUp<CR>", desc = "Move Pane Up", silent = true  },
34
    { "<leader>zd", ":NeolijMovePaneDown<CR>", desc = "Move Pane Down", silent = true  },
35
    { "<leader>zh", ":NeolijMovePaneLeft<CR>", desc = "Move Pane Left", silent = true  },
36
    { "<leader>zR", ":NeolijMovePaneRight<CR>", desc = "Move Pane Right", silent = true  },
37
  },
38
}
39
```
40
41
### Zellij
42
43
44
<details>
45
  <summary>Autolock plugin</summary>
46
47
```kdl
48
keybinds clear-defaults=true {
49
    shared_except "locked" {
50
        bind "Ctrl left" { MoveFocusOrTab "left"; }
51
        bind "Ctrl down" { MoveFocus "down"; }
52
        bind "Ctrl up" { MoveFocus "up"; }
53
        bind "Ctrl right" { MoveFocusOrTab "right"; }
54
    }
55
}
56
57
plugins {
58
    // Required
59
    autolock location="https://github.com/fresh2dev/zellij-autolock/releases/latest/download/zellij-autolock.wasm" {
60
        // Enabled at start?
61
        is_enabled true
62
        // Lock when any open these programs open.
63
        triggers "nvim|vim"
64
        // Reaction to input occurs after this many seconds. (default=0.3)
65
        // (An existing scheduled reaction prevents additional reactions.)
66
        reaction_seconds "0.3"
67
        // Print to Zellij log? (default=false)
68
        print_to_log false
69
    }
70
71
    // OR
72
73
    vim_zellij_navigator location="https://github.com/hiasr/vim-zellij-navigator/releases/download/0.3.0/vim-zellij-navigator.wasm"
74
}
75
76
// Plugins to load in the background when a new session starts
77
load_plugins {
78
    autolock
79
}
80
```
81
</details>
82
83
<details>
84
  <summary>vim-zellij-navigator plugin</summary>
85
86
> [!NOTE] 
87
> if you use `vim-zellij-navigator` you have to set `vim_zellij_navigator = true` in the configuration.
88
> ```lua
89
> require("neolij").setup({
90
>   vim_zellij_navigator = true
91
> })
92
> ```
93
94
```kdl
95
keybinds clear-defaults=true {
96
    shared_except "locked" {
97
        bind "Ctrl j" {
98
            MessagePlugin "vim_zellij_navigator" {
99
                name "move_focus";
100
                payload "down";
101
102
                move_mod "ctrl";
103
                use_arrow_keys "false";
104
            };
105
        }
106
107
        bind "Ctrl k" {
108
            MessagePlugin "vim_zellij_navigator" {
109
                name "move_focus";
110
                payload "up";
111
112
                move_mod "ctrl";
113
                use_arrow_keys "false";
114
            };
115
        }
116
117
        bind "Ctrl l" {
118
            MessagePlugin "vim_zellij_navigator" {
119
                name "move_focus_or_tab";
120
                payload "right";
121
122
                move_mod "ctrl"; // Optional, should be added on every command if you want to use it
123
                use_arrow_keys "false";
124
            };
125
        }
126
127
        bind "Alt h" {
128
            MessagePlugin "vim_zellij_navigator" {
129
                name "resize";
130
                payload "left";
131
132
                resize_mod "alt"; 
133
            };
134
        }
135
136
        bind "Alt j" {
137
            MessagePlugin "vim_zellij_navigator" {
138
                name "resize";
139
                payload "down";
140
141
                resize_mod "alt";
142
            };
143
        }
144
145
        bind "Alt k" {
146
            MessagePlugin "vim_zellij_navigator" {
147
                name "resize";
148
                payload "up";
149
150
                resize_mod "alt";
151
            };
152
        }
153
154
        bind "Alt l" {
155
            MessagePlugin "vim_zellij_navigator" {
156
                name "resize";
157
                payload "right";
158
159
                resize_mod "alt";
160
            };
161
        }
162
    }
163
}
164
165
plugins {
166
    vim_zellij_navigator location="https://github.com/hiasr/vim-zellij-navigator/releases/download/0.3.0/vim-zellij-navigator.wasm"
167
}
168
```
169
</details>
170
171
172
173
## Commands
174
### Navigation
175
| Command | Function | Description |
176
| --------------- | --------------- | --------------- |
177
| `:NeolijUp` | require("neolij").move("up") | Move up |
178
| `:NeolijDown` | require("neolij").move("down") | Move down |
179
| `:NeolijLeft` | require("neolij").move("left") | Move left |
180
| `:NeolijRight` | require("neolij").move("right") | Move right |
181
| `:NeolijLeftTab` | require("neolij").move_or_tab("left", false) | Move left or switch tab (zellij tabs) |
182
| `:NeolijRightTab` | require("neolij").move_or_tab("right", false) | Move right or switch tab (zellij tabs) |
183
| `:NeolijLeftSmart` | require("neolij").move_or_tab("left", true) | Move left or switch tab (nvim tab or zellij tab) |
184
| `:NeolijRightSmart` | require("neolij").move_or_tab("right", true) | Move right or switch tab (nvim tab or zellij tab) |
185
186
187
### Tab Managment
188
> [!TIP]
189
> If `name` is not provided, you will be prompted for input.
190
191
> [!TIP]
192
> type this in the terminal to see possible arguments
193
> ```sh
194
> zellij action new-tab --help
195
> ```
196
197
| Command | Function | Description |
198
| --------------- | --------------- | --------------- |
199
| `:NeolijNewTab [args?]` | require("neolij").new_tab(args?) | Create new tab |
200
| `:NeolijRenameTab [name?]` | require("neolij").rename_tab(name?) | Rename current zellij tab  |
201
| `:NeolijMoveTabLeft` | require("neolij").move_tab("left") | Move tab left |
202
| `:NeolijMoveTabRight` | require("neolij").move_tab("right") | Move tab right |
203
204
205
### Pane Managment
206
> [!TIP]
207
> If `name` is not provided, you will be prompted for input. 
208
209
> [!TIP]
210
> type this in the terminal to see possible arguments
211
> ```sh
212
> zellij action new-pane --help
213
> ```
214
215
| Command | Function | Description |
216
| --------------- | --------------- | --------------- |
217
| `:NeolijNewPane [args?]` | require("neolij").new_pane(args?) | Create new pane |
218
| `:NeolijRenamePane [name?]` | require("neolij").rename_pane(name?) | Rename current zellij pane  |
219
| `:NeolijMovePaneUp` | require("neolij").move_pane("up") | Move pane up |
220
| `:NeolijMovePaneDown` | require("neolij").move_pane("down") | Move pane down |
221
| `:NeolijMovePaneLeft` | require("neolij").move_pane("left") | Move pane left |
222
| `:NeolijMovePaneRight` | require("neolij").move_pane("right") | Move pane right |
223
224
### Custom
225
You can run any zellij action using:
226
```lua
227
require("neolij").zellij_action("toggle-fullscreen")
228
```
229
230
> [!TIP]
231
> type this in terminal to see possible actions 
232
>```sh
233
>zellij action help
234
>```
235
236
#### Examples
237
##### Toggle fullscreen for the current zellij pane
238
```lua
239
require("neolij").zellij_action("toggle-fullscreen")
240
```
241
242
##### Create a pane while asking for direction and name:
243
```lua
244
245
vim.keymap.set(
246
  "n",
247
  "<leader>zP",
248
  function()
249
    local dir = vim.fn.input("Direction (up/down/left/right): ")
250
    if dir == "" then
251
      -- default direction 
252
      dir = "right"
253
    end
254
255
    local name = vim.fn.input("Pane name: ")
256
257
    if name == "" then
258
      -- default name 
259
      name = "Pane"
260
    end
261
262
    local args = "-d " .. dir
263
    if name ~= "" then
264
      args = args .. " -n " .. name
265
    end
266
267
    require("neolij").new_pane({ args = args })
268
  end,
269
  { desc = "Neolij: New pane (ask direction & name)" }
270
)
271
272
```