From 1631f07c735797c9ff856d541aa4598798b97415 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 27 Nov 2024 10:23:35 +0100 Subject: [PATCH] perf: use blnd hl groups (#24) * perf: use blend hl groups * fix(draw): normalfloat instead of normal * fix(color): blend should always be 0 for hl groups to work --- lua/smear_cursor/color.lua | 4 ++-- lua/smear_cursor/draw.lua | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lua/smear_cursor/color.lua b/lua/smear_cursor/color.lua index 8ae483f..229a1e2 100644 --- a/lua/smear_cursor/color.lua +++ b/lua/smear_cursor/color.lua @@ -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 = 0 }) + vim.api.nvim_set_hl(0, blended_hl_group_inverted, { fg = normal_bg, bg = blended_cursor_color, blend = 0 }) end end diff --git a/lua/smear_cursor/draw.lua b/lua/smear_cursor/draw.lua index 40c4246..47d090f 100644 --- a/lua/smear_cursor/draw.lua +++ b/lua/smear_cursor/draw.lua @@ -53,7 +53,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 = "NormalFloat:Normal", winblend = 100 }) vim.o.ei = ei M.wins[tab].wins[M.wins[tab].active] = { win = window_id, buf = buffer_id } vim.api.nvim_create_autocmd("BufWipeout", { buffer = buffer_id, callback = vim.schedule_wrap(M.check_wins) }) @@ -82,9 +82,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, @@ -97,7 +96,6 @@ M.clear = function() for w = 1, M.wins[tab].active do local win = M.wins[tab].wins[w] if win and vim.api.nvim_win_is_valid(win.win) then - M.wo(win.win, { winblend = 100 }) vim.api.nvim_buf_clear_namespace(win.buf, cursor_namespace, 0, -1) vim.api.nvim_win_set_config(win.win, { relative = "editor", row = 0, col = 0 }) end