mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-25 00:44:52 +01:00
fix: dont require window until its used
so that config can be properly loaded first
This commit is contained in:
parent
8a12b109ff
commit
335ea236c4
4 changed files with 14 additions and 12 deletions
|
@ -21,8 +21,13 @@ local function attach(name, buffer, content, nowait)
|
|||
vim.api.nvim_set_option_value('fileformat', 'unix', { buf = buffer })
|
||||
vim.api.nvim_buf_set_name(buffer, name)
|
||||
local controller = session.workspace:attach_buffer(name):await()
|
||||
|
||||
if not nowait then
|
||||
controller:poll():await() -- wait for current state to get synched
|
||||
local promise = controller:poll()
|
||||
for i=1, 20, 1 do
|
||||
if promise.ready then break end
|
||||
vim.uv.sleep(100)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO map name to uuid
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
local native = require("codemp.loader").load()
|
||||
local window = require("codemp.window")
|
||||
local session = require("codemp.session")
|
||||
local workspace = require("codemp.workspace")
|
||||
|
||||
|
@ -8,7 +7,7 @@ local function connect(host, username, password)
|
|||
if username == nil then username = vim.g.codemp_username or vim.fn.input("username > ", "") end
|
||||
if password == nil then password = vim.g.codemp_password or vim.fn.input("password > ", "") end
|
||||
session.client = native.connect(host, username, password):await()
|
||||
window.update()
|
||||
require('codemp.window').update()
|
||||
vim.schedule(function () workspace.list() end)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ local session = require('codemp.session')
|
|||
local buffers = require('codemp.buffers')
|
||||
local workspace = require('codemp.workspace')
|
||||
local utils = require('codemp.utils')
|
||||
local window = require('codemp.window')
|
||||
local client = require("codemp.client")
|
||||
|
||||
local function filter(needle, haystack)
|
||||
|
@ -18,7 +17,7 @@ end
|
|||
-- always available
|
||||
local base_actions = {
|
||||
toggle = function()
|
||||
window.toggle()
|
||||
require('codemp.window').toggle()
|
||||
end,
|
||||
|
||||
connect = function(host)
|
||||
|
@ -88,7 +87,7 @@ local joined_actions = {
|
|||
if not bang then buffers.create(path) end
|
||||
local content = utils.buffer.get_content(buf)
|
||||
buffers.attach(path, buf, content)
|
||||
window.update() -- TODO would be nice to do automatically inside
|
||||
require('codemp.window').update() -- TODO would be nice to do automatically inside
|
||||
else
|
||||
print(" !! empty path or open a file")
|
||||
end
|
||||
|
@ -123,7 +122,7 @@ local joined_actions = {
|
|||
detach = function(path)
|
||||
if path == nil then error("missing buffer name") end
|
||||
buffers.detach(path)
|
||||
window.update() -- TODO would be nice to do automatically inside
|
||||
require('codemp.window').update() -- TODO would be nice to do automatically inside
|
||||
end,
|
||||
|
||||
leave = function(ws)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local utils = require('codemp.utils')
|
||||
local buffers = require('codemp.buffers')
|
||||
local session = require('codemp.session')
|
||||
local window = require('codemp.window')
|
||||
|
||||
local user_hl = {}
|
||||
|
||||
|
@ -22,7 +21,7 @@ local function fetch_workspaces_list()
|
|||
})
|
||||
end
|
||||
session.available = new_list
|
||||
window.update()
|
||||
require('codemp.window').update()
|
||||
end
|
||||
|
||||
---@param ws Workspace
|
||||
|
@ -72,7 +71,7 @@ local function register_cursor_handler(ws)
|
|||
)
|
||||
end
|
||||
if old_buffer ~= event.buffer then
|
||||
window.update() -- redraw user positions
|
||||
require('codemp.window').update() -- redraw user positions
|
||||
end
|
||||
end
|
||||
end))
|
||||
|
@ -99,11 +98,11 @@ local function join(workspace)
|
|||
-- end)
|
||||
-- end
|
||||
-- end
|
||||
-- vim.schedule(function() window.update() end)
|
||||
-- vim.schedule(function() require('codemp.window').update() end)
|
||||
-- end)
|
||||
|
||||
session.workspace = ws
|
||||
window.update()
|
||||
require('codemp.window').update()
|
||||
|
||||
return ws
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue