chore: moved colors in utils

This commit is contained in:
əlemi 2024-08-17 04:26:34 +02:00
parent 625bcb504d
commit 6ca8a15369
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 17 additions and 10 deletions

View file

@ -1,5 +1,19 @@
local native = require('codemp.loader').load()
local available_colors = { -- TODO these are definitely not portable!
"ErrorMsg",
"WarningMsg",
"MatchParen",
"SpecialMode",
"CmpItemKindFunction",
"CmpItemKindValue",
"CmpItemKindInterface",
}
local function color(x)
return available_colors[ (native.hash(x) % #available_colors) + 1 ]
end
local function order_tuples(x) -- TODO send help...
if x[1][1] < x[2][1] then
return { { x[1][1], x[1][2] }, { x[2][1], x[2][2] } }
@ -149,4 +163,6 @@ return {
replace_content = buffer_replace_content,
},
hash = native.hash,
available_colors = available_colors,
color = color,
}

View file

@ -7,15 +7,6 @@ local window = require('codemp.window')
local user_hl = {}
local tree_buf = nil
local available_colors = { -- TODO these are definitely not portable!
"ErrorMsg",
"WarningMsg",
"MatchParen",
"SpecialMode",
"CmpItemKindFunction",
"CmpItemKindValue",
"CmpItemKindInterface",
}
local function register_cursor_callback(controller)
vim.api.nvim_create_autocmd({"CursorMoved", "CursorMovedI", "ModeChanged"}, {
@ -38,7 +29,7 @@ local function register_cursor_handler(controller)
if user_hl[event.user] == nil then
user_hl[event.user] = {
ns = vim.api.nvim_create_namespace("codemp-cursor-" .. event.user),
hi = available_colors[ math.random( #available_colors ) ],
hi = utils.color(event.user),
}
end
local old_buffer = buffers.users[event.user]