Draft
Conversation
- 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.
cultab
commented
Mar 26, 2026
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 |
Owner
Author
There was a problem hiding this comment.
no, use the pane_id you get when you split
| 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 } |
Owner
Author
There was a problem hiding this comment.
here, don't discard the returned id
| return | ||
| end | ||
| local neighbor | ||
| if direction.new == 'right' then |
Owner
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
just trying Cursor out