diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..2278abd --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 100 diff --git a/lua/zellij-nav/init.lua b/lua/zellij-nav/init.lua index ab0d53c..6777de1 100644 --- a/lua/zellij-nav/init.lua +++ b/lua/zellij-nav/init.lua @@ -1,43 +1,43 @@ local M = {} local function nav(short_direction, direction) - -- get window ID, try switching windows, and get ID again to see if it worked - local cur_winnr = vim.fn.winnr() - vim.api.nvim_command("wincmd " .. short_direction) - local new_winnr = vim.fn.winnr() + -- get window ID, try switching windows, and get ID again to see if it worked + local cur_winnr = vim.fn.winnr() + vim.api.nvim_command("wincmd " .. short_direction) + local new_winnr = vim.fn.winnr() - -- if the window ID didn't change, then we didn't switch - if cur_winnr == new_winnr then - vim.fn.system("zellij action move-focus " .. direction) - if vim.v.shell_error ~= 0 then - error("zellij executable not found in path") - end - end + -- if the window ID didn't change, then we didn't switch + if cur_winnr == new_winnr then + vim.fn.system("zellij action move-focus " .. direction) + if vim.v.shell_error ~= 0 then + error("zellij executable not found in path") + end + end end function M.up() - nav("k", "up") + nav("k", "up") end function M.down() - nav("j", "down") + nav("j", "down") end function M.right() - nav("l", "right") + nav("l", "right") end function M.left() - nav("h", "left") + nav("h", "left") end -- create our exported setup() function function M.setup(opts) - -- create our commands - vim.api.nvim_create_user_command("ZellijNavigateUp", M.up, {}) - vim.api.nvim_create_user_command("ZellijNavigateDown", M.down, {}) - vim.api.nvim_create_user_command("ZellijNavigateLeft", M.left, {}) - vim.api.nvim_create_user_command("ZellijNavigateRight", M.right, {}) + -- create our commands + vim.api.nvim_create_user_command("ZellijNavigateUp", M.up, {}) + vim.api.nvim_create_user_command("ZellijNavigateDown", M.down, {}) + vim.api.nvim_create_user_command("ZellijNavigateLeft", M.left, {}) + vim.api.nvim_create_user_command("ZellijNavigateRight", M.right, {}) end return M