mirror of
https://github.com/craftzdog/solarized-osaka.nvim.git
synced 2026-09-10 07:16:21 -04:00
Add blink.cmp hl groups and render colors in buffer with hipattern (#49)
* feat(blink): add blink hl groups * fix(label): remove comments and add helpful info * feat(render): render colors using hipattern * chore(unused): change unused comment to other
This commit is contained in:
parent
eebeb55b2b
commit
f4c68cdc5f
107
.lazy.lua
Normal file
107
.lazy.lua
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
local M = {
|
||||
module = "solarized-osaka",
|
||||
colorscheme = "solarized-osaka",
|
||||
opts = { plugins = { all = true } },
|
||||
globals = { vim = vim },
|
||||
cache = {},
|
||||
}
|
||||
|
||||
function M.reset()
|
||||
local colors = require("solarized-osaka.colors").setup()
|
||||
M.globals.colors = colors
|
||||
M.globals.c = colors
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param buf number
|
||||
function M.hl_group(name, buf)
|
||||
return vim.api.nvim_buf_get_name(buf):find("kinds") and "LspKind" .. name or name
|
||||
end
|
||||
|
||||
local function reload()
|
||||
for k in pairs(package.loaded) do
|
||||
if k:find("^" .. M.module) then
|
||||
package.loaded[k] = nil
|
||||
end
|
||||
end
|
||||
M.cache = {}
|
||||
require(M.module).setup(M.opts)
|
||||
M.reset()
|
||||
local colorscheme = vim.g.colors_name or M.colorscheme
|
||||
colorscheme = colorscheme:find(M.colorscheme) and colorscheme or M.colorscheme
|
||||
vim.cmd.colorscheme(colorscheme)
|
||||
local hi = require("mini.hipatterns")
|
||||
for _, buf in ipairs(require("mini.hipatterns").get_enabled_buffers()) do
|
||||
hi.update(buf)
|
||||
end
|
||||
end
|
||||
reload = vim.schedule_wrap(reload)
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("colorscheme_dev", { clear = true })
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "VeryLazy",
|
||||
group = augroup,
|
||||
callback = reload,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
group = augroup,
|
||||
pattern = "*/lua/" .. M.module .. "/**.lua",
|
||||
callback = reload,
|
||||
})
|
||||
|
||||
return {
|
||||
{
|
||||
"echasnovski/mini.hipatterns",
|
||||
opts = function(_, opts)
|
||||
local hi = require("mini.hipatterns")
|
||||
|
||||
opts.highlighters = opts.highlighters or {}
|
||||
|
||||
opts.highlighters = vim.tbl_extend("keep", opts.highlighters or {}, {
|
||||
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
|
||||
|
||||
hl_group = {
|
||||
pattern = function(buf)
|
||||
return vim.api.nvim_buf_get_name(buf):find("lua/" .. M.module) and '^%s*%[?"?()[%w%.@]+()"?%]?%s*='
|
||||
end,
|
||||
group = function(buf, match)
|
||||
local group = M.hl_group(match, buf)
|
||||
if group then
|
||||
if M.cache[group] == nil then
|
||||
M.cache[group] = false
|
||||
local hl = vim.api.nvim_get_hl(0, { name = group, link = false, create = false })
|
||||
if not vim.tbl_isempty(hl) then
|
||||
hl.fg = hl.fg or vim.api.nvim_get_hl(0, { name = "Normal", link = false }).fg
|
||||
M.cache[group] = true
|
||||
vim.api.nvim_set_hl(0, group .. "Dev", hl)
|
||||
end
|
||||
end
|
||||
return M.cache[group] and group .. "Dev" or nil
|
||||
end
|
||||
end,
|
||||
extmark_opts = { priority = 2000 },
|
||||
},
|
||||
|
||||
hl_color = {
|
||||
pattern = {
|
||||
"%f[%w]()c%.[%w_%.]+()%f[%W]",
|
||||
"%f[%w]()colors%.[%w_%.]+()%f[%W]",
|
||||
"%f[%w]()vim%.g%.terminal_color_%d+()%f[%W]",
|
||||
},
|
||||
group = function(_, match)
|
||||
local parts = vim.split(match, ".", { plain = true })
|
||||
local color = vim.tbl_get(M.globals, unpack(parts))
|
||||
return type(color) == "string" and require("mini.hipatterns").compute_hex_color_group(color, "fg")
|
||||
end,
|
||||
extmark_opts = function(_, _, data)
|
||||
return {
|
||||
virt_text = { { "⬤ ", data.hl_group } },
|
||||
virt_text_pos = "inline",
|
||||
priority = 2000,
|
||||
}
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -667,6 +667,59 @@ function M.setup()
|
|||
-- LightspeedUniqueChar = { link = "LightspeedUnlabeledMatch" },
|
||||
LightspeedUnlabeledMatch = { fg = c.violet500, bold = true },
|
||||
|
||||
--Blink-cmp
|
||||
BlinkCmpLabel = { fg = c.fg, bg = c.none },
|
||||
BlinkCmpLabelDeprecated = { fg = c.base01, bg = c.none, strikethrough = true },
|
||||
--INFO: unused at the moment but passed still for future use
|
||||
BlinkCmpLabelMatch = { fg = c.violet500, bg = c.none },
|
||||
|
||||
-- Documentation windows
|
||||
BlinkCmpDoc = { fg = c.fg, bg = c.bg_float },
|
||||
BlinkCmpDocBorder = { fg = c.base02, bg = c.bg_float },
|
||||
BlinkCmpGhostText = { fg = c.base01 },
|
||||
|
||||
-- Signature help
|
||||
BlinkCmpSignatureHelp = { fg = c.violet500, bg = c.none },
|
||||
BlinkCmpSignatureHelpBorder = { fg = c.base02, bg = c.none },
|
||||
BlinkCmpSignatureHelpActiveParameter = { fg = c.orange, bg = c.none },
|
||||
|
||||
-- ISSUE: passing c.none causes menu to be invisible
|
||||
-- BlinkCmpMenu = { fg = c.base01, bg = c.none },
|
||||
BlinkCmpMenu = { fg = c.base01, bg = c.base02 },
|
||||
|
||||
BlinkCmpKindDefault = { fg = c.base01, bg = c.none }, -- Default fallback
|
||||
|
||||
BlinkCmpKindCodeium = { fg = c.cyan500, bg = c.none },
|
||||
BlinkCmpKindCopilot = { fg = c.cyan500, bg = c.none },
|
||||
BlinkCmpKindTabNine = { fg = c.cyan500, bg = c.none },
|
||||
BlinkCmpKindSupermaven = { fg = c.cyan500, bg = c.none },
|
||||
|
||||
BlinkCmpKindKeyword = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindVariable = { fg = c.magenta, bg = c.none },
|
||||
BlinkCmpKindConstant = { fg = c.magenta, bg = c.none },
|
||||
BlinkCmpKindReference = { fg = c.magenta, bg = c.none },
|
||||
BlinkCmpKindValue = { fg = c.magenta, bg = c.none },
|
||||
|
||||
BlinkCmpKindFunction = { fg = c.blue, bg = c.none },
|
||||
BlinkCmpKindMethod = { fg = c.blue, bg = c.none },
|
||||
BlinkCmpKindConstructor = { fg = c.blue, bg = c.none },
|
||||
|
||||
BlinkCmpKindClass = { fg = c.orange, bg = c.none },
|
||||
BlinkCmpKindInterface = { fg = c.orange, bg = c.none },
|
||||
BlinkCmpKindStruct = { fg = c.orange, bg = c.none },
|
||||
BlinkCmpKindEvent = { fg = c.orange, bg = c.none },
|
||||
BlinkCmpKindEnum = { fg = c.orange, bg = c.none },
|
||||
BlinkCmpKindUnit = { fg = c.orange, bg = c.none },
|
||||
|
||||
BlinkCmpKindModule = { fg = c.yellow, bg = c.none },
|
||||
|
||||
BlinkCmpKindProperty = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindField = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindTypeParameter = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindEnumMember = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindOperator = { fg = c.cyan, bg = c.none },
|
||||
BlinkCmpKindSnippet = { fg = c.violet500, bg = c.none },
|
||||
|
||||
-- Cmp
|
||||
CmpDocumentation = { fg = c.fg, bg = c.bg_float },
|
||||
CmpDocumentationBorder = { fg = c.base02, bg = c.bg_float },
|
||||
|
|
@ -684,6 +737,7 @@ function M.setup()
|
|||
CmpItemKindCodeium = { fg = c.cyan500, bg = c.none },
|
||||
CmpItemKindCopilot = { fg = c.cyan500, bg = c.none },
|
||||
CmpItemKindTabNine = { fg = c.cyan500, bg = c.none },
|
||||
CmpItemKindSupermaven = { fg = c.cyan500, bg = c.none },
|
||||
|
||||
CmpItemKindKeyword = { fg = c.cyan, bg = c.none },
|
||||
CmpItemKindVariable = { fg = c.magenta, bg = c.none },
|
||||
|
|
|
|||
Loading…
Reference in a new issue