mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-24 16:34:50 +01:00
feat: parse user list upon connection
basically shows user which were already present when connecting to a workspace, rather than waiting for a cursor from them
This commit is contained in:
parent
38c59e8934
commit
7e80f71509
1 changed files with 11 additions and 1 deletions
|
@ -4,7 +4,7 @@ local buffers = require('codemp.buffers')
|
|||
---@class UserHighlight
|
||||
---@field ns integer namespace to use for this user
|
||||
---@field hi HighlightPair color for user to use
|
||||
---@field mark integer extmark id
|
||||
---@field mark integer | nil extmark id
|
||||
---@field pos [integer, integer] cursor start position of this user
|
||||
|
||||
---@type table<string, UserHighlight>
|
||||
|
@ -160,6 +160,15 @@ local function join(workspace)
|
|||
register_cursor_callback(ws)
|
||||
register_cursor_handler(ws)
|
||||
CODEMP.workspace = ws
|
||||
for _, user in pairs(CODEMP.workspace:user_list()) do
|
||||
buffers.users[user] = ""
|
||||
user_hl[user] = {
|
||||
ns = vim.api.nvim_create_namespace("codemp-cursor-" .. user),
|
||||
hi = utils.color(user),
|
||||
pos = { 0, 0 },
|
||||
mark = nil,
|
||||
}
|
||||
end
|
||||
require('codemp.window').update()
|
||||
utils.poller(
|
||||
function() return ws:event() end,
|
||||
|
@ -180,6 +189,7 @@ local function join(workspace)
|
|||
ns = vim.api.nvim_create_namespace("codemp-cursor-" .. event.value),
|
||||
hi = utils.color(event.value),
|
||||
pos = { 0, 0 },
|
||||
mark = nil,
|
||||
}
|
||||
end
|
||||
require('codemp.window').update()
|
||||
|
|
Loading…
Reference in a new issue