chore: user->buffer mappings in buffers module

This commit is contained in:
əlemi 2024-08-17 03:28:08 +02:00
parent 7e97777997
commit 733dca385b
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 4 additions and 3 deletions

View file

@ -3,6 +3,7 @@ local state = require('codemp.state')
local id_buffer_map = {}
local buffer_id_map = {}
local user_buffer_name = {}
local ticks = {}
local function create(name, content)
@ -124,4 +125,5 @@ return {
map = id_buffer_map,
map_rev = buffer_id_map,
ticks = ticks,
users = user_buffer_name,
}

View file

@ -6,7 +6,6 @@ local state = require('codemp.state')
local window = require('codemp.window')
local user_hl = {}
local user_buffer = {}
local tree_buf = nil
local available_colors = { -- TODO these are definitely not portable!
"ErrorMsg",
@ -42,11 +41,11 @@ local function register_cursor_handler(controller)
hi = available_colors[ math.random( #available_colors ) ],
}
end
local old_buffer = user_buffer[event.user]
local old_buffer = buffers.users[event.user]
if old_buffer ~= nil then
vim.api.nvim_buf_clear_namespace(old_buffer, user_hl[event.user].ns, 0, -1)
end
user_buffer[event.user] = event.buffer
buffers.users[event.user] = event.buffer
local buffer = buffers.map_rev[event.buffer]
if buffer ~= nil then
utils.multiline_highlight(