Merge pull request #176 from nullchilly/main

refactor(performance): Improve nvim_set_hl
dev
Pocco81 2 years ago committed by GitHub
commit edd620668b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,7 +14,7 @@ function M.get(cp)
BufferLineFill = { bg = bg_highlight },
BufferLineBackcrust = { fg = cp.text, bg = inactive_bg }, -- others
BufferLineBufferVisible = { fg = cp.surface1, bg = inactive_bg },
BufferLineBufferSelected = { fg = cp.text, bg = cp.base, style = "bold,italic" }, -- current
BufferLineBufferSelected = { fg = cp.text, bg = cp.base, style = { "bold", "italic" } }, -- current
BufferLineTab = { fg = cp.surface1, bg = cp.base },
BufferLineTabSelected = { fg = cp.red, bg = cp.blue },
BufferLineTabClose = { fg = cp.red, bg = inactive_bg },

@ -2,9 +2,9 @@ local M = {}
function M.get(cp)
return {
HopNextKey = { bg = cp.base, fg = cp.peach, style = "bold,underline" },
HopNextKey = { bg = cp.base, fg = cp.peach, style = { "bold", "underline" } },
HopNextKey1 = { bg = cp.base, fg = cp.blue, style = "bold" },
HopNextKey2 = { bg = cp.base, fg = cp.teal, style = "bold,italic" },
HopNextKey2 = { bg = cp.base, fg = cp.teal, style = { "bold", "italic" } },
HopUnmatched = { bg = cp.base, fg = cp.overlay0 },
}
end

@ -17,7 +17,7 @@ function M.get(cp)
MiniJump = { fg = cp.overlay2, bg = cp.pink },
MiniJump2dSpot = { bg = cp.base, fg = cp.peach, style = "bold,underline" },
MiniJump2dSpot = { bg = cp.base, fg = cp.peach, style = { "bold", "underline" } },
MiniStarterCurrent = {},
MiniStarterFooter = { fg = cp.yellow, style = "italic" },
@ -42,10 +42,10 @@ function M.get(cp)
MiniSurround = { bg = cp.pink, fg = cp.surface1 },
MiniTablineCurrent = { fg = cp.text, bg = cp.base, style = "bold,italic" },
MiniTablineCurrent = { fg = cp.text, bg = cp.base, style = { "bold", "italic" } },
MiniTablineFill = { bg = bg_highlight },
MiniTablineHidden = { fg = cp.text, bg = inactive_bg },
MiniTablineModifiedCurrent = { fg = cp.base, bg = cp.text, style = "bold,italic" },
MiniTablineModifiedCurrent = { fg = cp.base, bg = cp.text, style = { "bold", "italic" } },
MiniTablineModifiedHidden = { fg = inactive_bg, bg = cp.text },
MiniTablineModifiedVisible = { fg = cp.surface1, bg = cp.subtext1 },
MiniTablineTabpagesection = { fg = cp.surface1, bg = cp.base },

@ -80,7 +80,7 @@ function M.get(cp)
-- TSURI = { }; -- Any URI like a link or email.
--
-- Markdown tresitter parser support
TSURI = { fg = cp.rosewater, style = "italic,underline" }, -- urls, links and emails
TSURI = { fg = cp.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
TSLiteral = { fg = cp.teal, style = "italic" }, -- used for inline code in markdown and for doc in python (""")
TSTextReference = { fg = cp.lavender, style = "bold" }, -- references
TSTitle = { fg = cp.blue, style = "bold" }, -- titles like: # Example

@ -34,7 +34,7 @@ local function get_base()
}, -- Screen-line at the cursor, when 'cursorline' is secp. Low-priority if forecrust (ctermfg OR guifg) is not secp.
Directory = { fg = cp.blue }, -- directory names (and other special names in listings)
EndOfBuffer = { fg = cp.base }, -- filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|.
ErrorMsg = { fg = cp.red, style = "bold,italic" }, -- error messages on the command line
ErrorMsg = { fg = cp.red, style = { "bold", "italic" } }, -- error messages on the command line
VertSplit = { fg = cp.crust }, -- the column separating vertically split windows
Folded = { fg = cp.blue, bg = cp.surface1 }, -- line used for closed folds
FoldColumn = { bg = cp.base, fg = cp.overlay0 }, -- 'foldcolumn'

@ -8,13 +8,4 @@ function M.set_of(list)
return set
end
-- https://www.codegrepper.com/code-examples/lua/lua+split+string+on+comma
function M.split(s, delimiter)
local result = {}
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
return M

@ -1,9 +1,6 @@
local udata = require("catppuccin.utils.data")
local g = vim.g
local util = {}
local has_nvim07 = vim.fn.has("nvim-0.7")
function util.highlight(group, color)
@ -15,8 +12,12 @@ function util.highlight(group, color)
else
if color.style then
if color.style ~= "NONE" then
for _, style in pairs(udata.split(color.style, ",")) do
color[style] = true
if type(color.style) == "table" then
for _, style in ipairs(color.style) do
color[style] = true
end
else
color[color.style] = true
end
end
end
@ -26,6 +27,9 @@ function util.highlight(group, color)
end
else
-- Doc: :h highlight-gui
if color.style and type(color.style) == "table" then
color.style = table.concat(color.style, ",")
end
local style = color.style and "gui=" .. color.style or "gui=NONE"
local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE"
local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE"

Loading…
Cancel
Save