index : neolij.nvim
Seamless Neovim/Zellij integration with built-in navigation, pane/tab management, and Lua scripting.
about summary refs log tree commit diff
author y2w8 <yousefalharby416@gmail.com> 2025-12-13 11:44:39 +0300
committer y2w8 <yousefalharby416@gmail.com> 2025-12-13 11:44:39 +0300
commit 7839dbffb7896e1f45f1d6fb0d106d814de09c10 [patch]
tree 3df8ca2a6aefe6828b48439fd484b9066db86cea
parent 1e8f22790a35add7c89cd2e8079925a812d4a170
download 7839dbffb7896e1f45f1d6fb0d106d814de09c10.tar.gz

Add Comments

Diffstat

-rw-r--r-- lua/zellij/init.lua 8
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lua/zellij/init.lua b/lua/zellij/init.lua
index b863cab..fca6cf2 100644
--- a/lua/zellij/init.lua
+++ b/lua/zellij/init.lua
@@ -1,5 +1,6 @@
local M = {}

-- Modes
local MODE = {
  WINDOW = "window",
  TAB = "tab",
@@ -11,7 +12,7 @@
    left = "h",
    right = "l",
  }

-- Run zellij action safely
local function zellij_action(args)
  vim.fn.system("zellij action " .. args)
  if vim.v.shell_error ~= 0 then
@@ -19,24 +20,29 @@
  end
end

-- Try vim window move, fallback to zellij
local function navigate(direction, vim_key, fallback)
  local before = vim.fn.winnr()
  vim.cmd("wincmd " .. vim_key)
  local after = vim.fn.winnr()

  -- If vim didn't move, fallback to zellij
  if before == after then
    zellij_action(fallback .. " " .. direction)
  end
end

-- Window navigation
function M.move(direction)
  navigate(direction, direction_translation[direction], "move-focus")
end

-- Window navigation or tab switch
function M.move_or_tab(direction)
  navigate(direction, direction_translation[direction], "move-focus-or-tab")
end

-- Setup user commands
function M.setup()
  vim.api.nvim_create_user_command("ZellijUp", function() M.move("up") end, {})
  vim.api.nvim_create_user_command("ZellijDown", function() M.move("down") end, {})