Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use blend hl groups #24

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 0 })
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 @@ -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) })
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down