mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-15 19:45:46 +08:00
fix(cpicker): fix get cursor color function
This commit is contained in:
parent
f6deb0bd9a
commit
e143116bc5
@ -52,12 +52,34 @@ function M.set_default_color(formats)
|
|||||||
end
|
end
|
||||||
local inspect = vim.inspect_pos()
|
local inspect = vim.inspect_pos()
|
||||||
local hex
|
local hex
|
||||||
if #inspect.treesitter > 0 then
|
if #inspect.semantic_tokens > 0 then
|
||||||
|
local token, priority = {}, 0
|
||||||
|
for _, semantic_token in ipairs(inspect.semantic_tokens) do
|
||||||
|
if semantic_token.opts.priority > priority then
|
||||||
|
priority = semantic_token.opts.priority
|
||||||
|
token = semantic_token
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if token then
|
||||||
|
local fg = vim.api.nvim_get_hl(0, { name = token.opts.hl_group_link }).fg
|
||||||
|
if fg then
|
||||||
|
hex = string.format('#%06X', fg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif #inspect.treesitter > 0 then
|
||||||
local fg =
|
local fg =
|
||||||
vim.api.nvim_get_hl(0, { name = inspect.treesitter[#inspect.treesitter].hl_group_link }).fg
|
vim.api.nvim_get_hl(0, { name = inspect.treesitter[#inspect.treesitter].hl_group_link }).fg
|
||||||
if fg then
|
if fg then
|
||||||
hex = string.format('#%06X', fg)
|
hex = string.format('#%06X', fg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i = #inspect.treesitter, 1, -1 do
|
||||||
|
local fg = vim.api.nvim_get_hl(0, { name = inspect.treesitter[i].hl_group_link }).fg
|
||||||
|
if fg then
|
||||||
|
hex = string.format('#%06X', fg)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local name = vim.fn.synIDattr(vim.fn.synID(vim.fn.line('.'), vim.fn.col('.'), 1), 'name', 'gui')
|
local name = vim.fn.synIDattr(vim.fn.synID(vim.fn.line('.'), vim.fn.col('.'), 1), 'name', 'gui')
|
||||||
local fg = get_color(name).fg
|
local fg = get_color(name).fg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user