fix: pass callback arg, add available field

This commit is contained in:
əlemi 2024-09-17 17:58:32 +02:00
parent 32e056de91
commit 2e26df05e2
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 6 additions and 3 deletions

View file

@ -9,6 +9,7 @@ local function connect()
if tmp_cfg.password == nil or #tmp_cfg.password == 0 then
tmp_cfg.password = vim.g.codemp_password or vim.fn.input("password > ", "")
end
print(" -- connecting ...")
CODEMP.native.connect(tmp_cfg):and_then(function (client)
print(" ++ connected")
CODEMP.client = client

View file

@ -7,7 +7,7 @@ if CODEMP == nil then
---@field rt? RuntimeDriver background codemp runtime
---@field client? Client currently connected client
---@field workspace? Workspace current active workspace
---@field available? WorkspaceReference[] available workspaces to connect to
---@field available WorkspaceReference[] available workspaces to connect to
---@field timer? any libuv timer
---@field config Config codemp configuration
---@field setup fun(opts: Config): nil update codemp configuration
@ -15,6 +15,7 @@ if CODEMP == nil then
rt = nil,
native = nil,
timer = nil,
available = {},
config = {
neo_tree = false,
timer_interval = 20,
@ -58,9 +59,9 @@ if CODEMP.timer == nil then
CODEMP.timer = vim.loop.new_timer()
CODEMP.timer:start(CODEMP.config.timer_interval, CODEMP.config.timer_interval, function()
while true do
local cb = CODEMP.native.poll_callback()
local cb, arg = CODEMP.native.poll_callback()
if cb == nil then break end
vim.schedule(function() cb() end)
vim.schedule(function() cb(arg) end)
end
end)

View file

@ -108,6 +108,7 @@ end
---@param workspace string workspace name to join
---join a workspace and register event handlers
local function join(workspace)
print(" <> joining workspace " .. workspace .. " ...")
CODEMP.client:join_workspace(workspace):and_then(function (ws)
print(" >< joined workspace " .. ws.name)
register_cursor_callback(ws)