Allow move-focus-or-tab as action
This commit is contained in:
1 file changed
+16
-10
+16
-10
@@ -1,6 +1,12 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function nav(short_direction, direction)
|
local function nav(short_direction, direction, action)
|
||||||
|
action = action or "move-focus"
|
||||||
|
|
||||||
|
if action ~= "move-focus" and action ~= "move-focus-or-tab" then
|
||||||
|
error("invalid action: " .. action)
|
||||||
|
end
|
||||||
|
|
||||||
-- get window ID, try switching windows, and get ID again to see if it worked
|
-- get window ID, try switching windows, and get ID again to see if it worked
|
||||||
local cur_winnr = vim.fn.winnr()
|
local cur_winnr = vim.fn.winnr()
|
||||||
vim.api.nvim_command("wincmd " .. short_direction)
|
vim.api.nvim_command("wincmd " .. short_direction)
|
||||||
@@ -8,27 +14,27 @@ local function nav(short_direction, direction)
|
|||||||
|
|
||||||
-- if the window ID didn't change, then we didn't switch
|
-- if the window ID didn't change, then we didn't switch
|
||||||
if cur_winnr == new_winnr then
|
if cur_winnr == new_winnr then
|
||||||
vim.fn.system("zellij action move-focus " .. direction)
|
vim.fn.system("zellij action " .. action .. " " .. direction)
|
||||||
if vim.v.shell_error ~= 0 then
|
if vim.v.shell_error ~= 0 then
|
||||||
error("zellij executable not found in path")
|
error("zellij executable not found in path")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.up()
|
function M.up(action)
|
||||||
nav("k", "up")
|
nav("k", "up", action)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.down()
|
function M.down(action)
|
||||||
nav("j", "down")
|
nav("j", "down", action)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.right()
|
function M.right(action)
|
||||||
nav("l", "right")
|
nav("l", "right", action)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.left()
|
function M.left(action)
|
||||||
nav("h", "left")
|
nav("h", "left", action)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create our exported setup() function
|
-- create our exported setup() function
|
||||||
|
|||||||
Reference in new issue
Block a user