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 8b3aa325cd08117a44236e2a5c5fe09f54bc2694 6102 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
## Installing
5
### lazyvim
6
```lua
7
{
8
   "y2w8/neolij.nvim",
9
    event = "VeryLazy",
10
    opts = {}, -- Important even if empty
11
    keys = {
12
    -- Window navigation
13
    { "<C-k>", ":NeolijUp<CR>", mode = { "n", "t" }, desc = "Move up", silent = true  },
14
    { "<C-j>", ":NeolijDown<CR>", mode = { "n", "t" }, desc = "Move down", silent = true  },
15
    { "<C-h>", ":NeolijLeftTab<CR>", mode = { "n", "t" }, desc = "Move left", silent = true  },
16
    { "<C-l>", ":NeolijRightTab<CR>", mode = { "n", "t" }, desc = "Move right", silent = true  },
17
18
    -- Tab actions
19
    { "<leader>zt", ":NeolijNewTab<CR>", desc = "New Zellij Tab", silent = true  },
20
    { "<leader>zr", ":NeolijRenameTab<CR>", desc = "Rename Zellij Tab", silent = true  },
21
    { "<leader>zl", ":NeolijMoveTabLeft<CR>", desc = "Move Tab Left", silent = true  },
22
    { "<leader>zL", ":NeolijMoveTabRight<CR>", desc = "Move Tab Right", silent = true  },
23
24
    -- Pane actions
25
    { "<leader>zp", ":NeolijNewPane -d right<CR>", desc = "New Zellij Pane vertical", silent = true  },
26
    { "<leader>zP", ":NeolijNewPane -d down<CR>", desc = "New Zellij Pane horizontal", silent = true  },
27
    { "<leader>zf", ":NeolijNewPane -f<CR>", desc = "New Zellij Floating Pane", silent = true  },
28
    { "<leader>zn", ":NeolijRenamePane<CR>", desc = "Rename Zellij Pane", silent = true  },
29
    { "<leader>zu", ":NeolijMovePaneUp<CR>", desc = "Move Pane Up", silent = true  },
30
    { "<leader>zd", ":NeolijMovePaneDown<CR>", desc = "Move Pane Down", silent = true  },
31
    { "<leader>zh", ":NeolijMovePaneLeft<CR>", desc = "Move Pane Left", silent = true  },
32
    { "<leader>zR", ":NeolijMovePaneRight<CR>", desc = "Move Pane Right", silent = true  },
33
  },
34
}
35
```
36
37
### Zellij
38
```kdl
39
40
keybinds clear-defaults=true {
41
    shared_except "locked" {
42
        bind "Ctrl left" { MoveFocusOrTab "left"; }
43
        bind "Ctrl down" { MoveFocus "down"; }
44
        bind "Ctrl up" { MoveFocus "up"; }
45
        bind "Ctrl right" { MoveFocusOrTab "right"; }
46
    }
47
}
48
49
plugins {
50
    // Required
51
    autolock location="https://github.com/fresh2dev/zellij-autolock/releases/latest/download/zellij-autolock.wasm" {
52
        // Enabled at start?
53
        is_enabled true
54
        // Lock when any open these programs open.
55
        triggers "nvim|vim"
56
        // Reaction to input occurs after this many seconds. (default=0.3)
57
        // (An existing scheduled reaction prevents additional reactions.)
58
        reaction_seconds "0.3"
59
        // Print to Zellij log? (default=false)
60
        print_to_log false
61
    }
62
}
63
64
// Plugins to load in the background when a new session starts
65
load_plugins {
66
    autolock
67
}
68
69
```
70
71
72
## Commands
73
### Navigation
74
| Command | Function | Description |
75
| --------------- | --------------- | --------------- |
76
| `:NeolijUp` | require("neolij").move("up") | Move up |
77
| `:NeolijDown` | require("neolij").move("down") | Move down |
78
| `:NeolijLeft` | require("neolij").move("left") | Move left |
79
| `:NeolijRight` | require("neolij").move("right") | Move right |
80
| `:NeolijLeftTab` | require("neolij").move_or_tab("left", false) | Move left or switch tab (zellij tabs) |
81
| `:NeolijRightTab` | require("neolij").move_or_tab("right", false) | Move right or switch tab (zellij tabs) |
82
| `:NeolijLeftSmart` | require("neolij").move_or_tab("left", true) | Move left or switch tab (nvim tab or zellij tab) |
83
| `:NeolijRightSmart` | require("neolij").move_or_tab("right", true) | Move right or switch tab (nvim tab or zellij tab) |
84
85
86
### Tab Managment
87
> [!TIP]
88
> If `name` is not provided, you will be prompted for input.
89
90
> [!TIP]
91
> type this in the terminal to see possible arguments
92
> ```sh
93
> zellij action new-tab --help
94
> ```
95
96
| Command | Function | Description |
97
| --------------- | --------------- | --------------- |
98
| `:NeolijNewTab [args?]` | require("neolij").new_tab(args?) | Create new tab |
99
| `:NeolijRenameTab [name?]` | require("neolij").rename_tab(name?) | Rename current zellij tab  |
100
| `:NeolijMoveTabLeft` | require("neolij").move_tab("left") | Move tab left |
101
| `:NeolijMoveTabRight` | require("neolij").move_tab("right") | Move tab right |
102
103
104
### Pane Managment
105
> [!TIP]
106
> If `name` is not provided, you will be prompted for input. 
107
108
> [!TIP]
109
> type this in the terminal to see possible arguments
110
> ```sh
111
> zellij action new-pane --help
112
> ```
113
114
| Command | Function | Description |
115
| --------------- | --------------- | --------------- |
116
| `:NeolijNewPane [args?]` | require("neolij").new_pane(args?) | Create new pane |
117
| `:NeolijRenamePane [name?]` | require("neolij").rename_pane(name?) | Rename current zellij pane  |
118
| `:NeolijMovePaneUp` | require("neolij").move_pane("up") | Move pane up |
119
| `:NeolijMovePaneDown` | require("neolij").move_pane("down") | Move pane down |
120
| `:NeolijMovePaneLeft` | require("neolij").move_pane("left") | Move pane left |
121
| `:NeolijMovePaneRight` | require("neolij").move_pane("right") | Move pane right |
122
123
### Custom
124
You can run any zellij action using:
125
```lua
126
require("neolij").zellij_action("toggle-fullscreen")
127
```
128
129
> [!TIP]
130
> type this in terminal to see possible actions 
131
>```sh
132
>zellij action help
133
>```
134
135
#### Examples
136
##### Toggle fullscreen for the current zellij pane
137
```lua
138
require("neolij").zellij_action("toggle-fullscreen")
139
```
140
141
##### Create a pane while asking for direction and name:
142
```lua
143
144
vim.keymap.set(
145
  "n",
146
  "<leader>zP",
147
  function()
148
    local dir = vim.fn.input("Direction (up/down/left/right): ")
149
    if dir == "" then
150
      -- default direction 
151
      dir = "right"
152
    end
153
154
    local name = vim.fn.input("Pane name: ")
155
156
    if name == "" then
157
      -- default name 
158
      name = "Pane"
159
    end
160
161
    local args = "-d " .. dir
162
    if name ~= "" then
163
      args = args .. " -n " .. name
164
    end
165
166
    require("neolij").new_pane({ args = args })
167
  end,
168
  { desc = "Neolij: New pane (ask direction & name)" }
169
)
170
171
```