mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
chore: moved colors in utils
This commit is contained in:
parent
625bcb504d
commit
6ca8a15369
2 changed files with 17 additions and 10 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue