Skip to content

add zellij support using Cursor AI#2

Draft
cultab wants to merge 4 commits intomainfrom
zellij-cursor
Draft

add zellij support using Cursor AI#2
cultab wants to merge 4 commits intomainfrom
zellij-cursor

Conversation

@cultab
Copy link
Copy Markdown
Owner

@cultab cultab commented Mar 25, 2026

just trying Cursor out

cultab and others added 4 commits March 25, 2026 15:24
- Implemented zellij backend in lua/command/zellij.lua
- Updated backend selection heuristics to recognize zellij
- Updated documentation to list zellij as a supported backend

Made-with: Cursor
Made-with: Cursor

end of the Cursor experiment.
Copy link
Copy Markdown
Owner Author

@cultab cultab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix this plox

Comment thread .vscode/settings.json
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delet this

Comment thread lua/command/zellij.lua
Comment on lines +34 to +111
local function overlaps_vertical(a, b)
local ay2 = a.pane_y + a.pane_rows
local by2 = b.pane_y + b.pane_rows
return math.max(a.pane_y, b.pane_y) < math.min(ay2, by2)
end

---@param a table
---@param b table
---@return boolean
local function overlaps_horizontal(a, b)
local ax2 = a.pane_x + a.pane_columns
local bx2 = b.pane_x + b.pane_columns
return math.max(a.pane_x, b.pane_x) < math.min(ax2, bx2)
end

---@param focused table
---@param panes table[]
---@return table|nil
local function find_right_neighbor(focused, panes)
local right_edge = focused.pane_x + focused.pane_columns
local best
local best_dist
for _, p in ipairs(panes) do
if not p.is_plugin and p.id ~= focused.id then
if p.pane_x >= right_edge and overlaps_vertical(focused, p) then
local dist = p.pane_x - right_edge
if not best or dist < best_dist then
best = p
best_dist = dist
end
end
end
end
return best
end

---@param focused table
---@param panes table[]
---@return table|nil
local function find_down_neighbor(focused, panes)
local bottom_edge = focused.pane_y + focused.pane_rows
local best
local best_dist
for _, p in ipairs(panes) do
if not p.is_plugin and p.id ~= focused.id then
if p.pane_y >= bottom_edge and overlaps_horizontal(focused, p) then
local dist = p.pane_y - bottom_edge
if not best or dist < best_dist then
best = p
best_dist = dist
end
end
end
end
return best
end

---@param panes table[]
---@return table|nil
local function find_focused_terminal(panes)
for _, p in ipairs(panes) do
if p.is_focused and not p.is_plugin then
return p
end
end
local zid = vim.env.ZELLIJ_PANE_ID
if zid then
local num = zid:match 'terminal_(%d+)' or zid:match '^(%d+)$'
if num then
for _, p in ipairs(panes) do
if not p.is_plugin and tostring(p.id) == num then
return p
end
end
end
end
return nil
end
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, use the pane_id you get when you split

Comment thread lua/command/zellij.lua
return nil, 'list-panes returned no data'
end
local before_ids = terminal_ids_set(before)
local _, split_err = system { 'zellij', 'action', 'new-pane', '--direction', dir }
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, don't discard the returned id

Comment thread lua/command/zellij.lua
return
end
local neighbor
if direction.new == 'right' then
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, get current pane id, try to move in direction.new if the id is not the same, run command in new id, else split in direction.new and run command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant