Skip to content

Commit

Permalink
perf: use blend hl groups
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 27, 2024
1 parent 42080c1 commit 335ae3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lua/smear_cursor/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ local function set_hl_groups()
local blended_hl_group_inverted = M.hl_group_inverted .. i
M.hl_groups[i] = blended_hl_group
M.hl_groups_inverted[i] = blended_hl_group_inverted
vim.api.nvim_set_hl(0, blended_hl_group, { fg = blended_cursor_color, bg = normal_bg })
vim.api.nvim_set_hl(0, blended_hl_group_inverted, { fg = normal_bg, bg = blended_cursor_color })
vim.api.nvim_set_hl(0, blended_hl_group, { fg = blended_cursor_color, bg = normal_bg, blend = 100 })
vim.api.nvim_set_hl(0, blended_hl_group_inverted, { fg = normal_bg, bg = blended_cursor_color, blend = 0 })
end
end

Expand Down
6 changes: 2 additions & 4 deletions lua/smear_cursor/draw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function M.get_win(tab, row, col)
local ei = vim.o.ei
vim.o.ei = "all" -- ignore all events
M.bo(buffer_id, { buftype = "nofile", bufhidden = "wipe", swapfile = false })
M.wo(window_id, { winhighlight = "Normal:Normal" })
M.wo(window_id, { winhighlight = "Normal:Normal", winblend = 100 })
vim.o.ei = ei
table.insert(M.wins[tab], { win = window_id, buf = buffer_id, used = true })
vim.api.nvim_create_autocmd("BufWipeout", { buffer = buffer_id, callback = vim.schedule_wrap(M.check_wins) })
Expand Down Expand Up @@ -83,9 +83,8 @@ M.draw_character = function(row, col, character, hl_group, L)
end
-- logging.debug("Drawing character " .. character .. " at (" .. row .. ", " .. col .. ")")
local current_tab = vim.api.nvim_get_current_tabpage()
local window_id, buffer_id = M.get_win(current_tab, row, col)
local _, buffer_id = M.get_win(current_tab, row, col)

M.wo(window_id, { winblend = config.legacy_computing_symbols_support and 100 or 0 })
vim.api.nvim_buf_set_extmark(buffer_id, cursor_namespace, 0, 0, {
virt_text = { { character, hl_group } },
virt_text_win_col = 0,
Expand All @@ -98,7 +97,6 @@ M.clear = function()
for _, w in ipairs(M.wins[tab]) do
if w.win and vim.api.nvim_win_is_valid(w.win) and w.used then
w.used = false
M.wo(w.win, { winblend = 100 })
vim.api.nvim_buf_clear_namespace(w.buf, cursor_namespace, 0, -1)
vim.api.nvim_win_set_config(w.win, { relative = "editor", row = 0, col = 0 })
end
Expand Down

0 comments on commit 335ae3f

Please sign in to comment.