mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
chore: user->buffer mappings in buffers module
This commit is contained in:
parent
7e97777997
commit
733dca385b
2 changed files with 4 additions and 3 deletions
|
@ -3,6 +3,7 @@ local state = require('codemp.state')
|
||||||
|
|
||||||
local id_buffer_map = {}
|
local id_buffer_map = {}
|
||||||
local buffer_id_map = {}
|
local buffer_id_map = {}
|
||||||
|
local user_buffer_name = {}
|
||||||
local ticks = {}
|
local ticks = {}
|
||||||
|
|
||||||
local function create(name, content)
|
local function create(name, content)
|
||||||
|
@ -124,4 +125,5 @@ return {
|
||||||
map = id_buffer_map,
|
map = id_buffer_map,
|
||||||
map_rev = buffer_id_map,
|
map_rev = buffer_id_map,
|
||||||
ticks = ticks,
|
ticks = ticks,
|
||||||
|
users = user_buffer_name,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ local state = require('codemp.state')
|
||||||
local window = require('codemp.window')
|
local window = require('codemp.window')
|
||||||
|
|
||||||
local user_hl = {}
|
local user_hl = {}
|
||||||
local user_buffer = {}
|
|
||||||
local tree_buf = nil
|
local tree_buf = nil
|
||||||
local available_colors = { -- TODO these are definitely not portable!
|
local available_colors = { -- TODO these are definitely not portable!
|
||||||
"ErrorMsg",
|
"ErrorMsg",
|
||||||
|
@ -42,11 +41,11 @@ local function register_cursor_handler(controller)
|
||||||
hi = available_colors[ math.random( #available_colors ) ],
|
hi = available_colors[ math.random( #available_colors ) ],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local old_buffer = user_buffer[event.user]
|
local old_buffer = buffers.users[event.user]
|
||||||
if old_buffer ~= nil then
|
if old_buffer ~= nil then
|
||||||
vim.api.nvim_buf_clear_namespace(old_buffer, user_hl[event.user].ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(old_buffer, user_hl[event.user].ns, 0, -1)
|
||||||
end
|
end
|
||||||
user_buffer[event.user] = event.buffer
|
buffers.users[event.user] = event.buffer
|
||||||
local buffer = buffers.map_rev[event.buffer]
|
local buffer = buffers.map_rev[event.buffer]
|
||||||
if buffer ~= nil then
|
if buffer ~= nil then
|
||||||
utils.multiline_highlight(
|
utils.multiline_highlight(
|
||||||
|
|
Loading…
Reference in a new issue