Skip to content

Commit

Permalink
feat(color): enable blending with legacy symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Nov 27, 2024
1 parent 1631f07 commit 0a487dc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions lua/smear_cursor/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ local function interpolate_colors(hex1, hex2, t)
return rgb_to_hex(r, g, b)
end

local function set_hl_groups()
M.set_hl_groups = function()
vim.api.nvim_set_hl(0, M.hl_group, { fg = cursor_color, bg = normal_bg })
vim.api.nvim_set_hl(0, M.hl_group_inverted, { fg = normal_bg, bg = cursor_color })

Expand All @@ -76,7 +76,11 @@ 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, blend = 0 })
vim.api.nvim_set_hl(
0,
blended_hl_group,
{ fg = blended_cursor_color, bg = normal_bg, blend = config.legacy_computing_symbols_support and 100 or 0 }
)
vim.api.nvim_set_hl(0, blended_hl_group_inverted, { fg = normal_bg, bg = blended_cursor_color, blend = 0 })
end
end
Expand All @@ -86,7 +90,7 @@ M.hl_group = "SmearCursorNormal"
M.hl_group_inverted = "SmearCursorNormalInverted"
M.hl_groups = {}
M.hl_groups_inverted = {}
set_hl_groups()
M.set_hl_groups()

local metatable = {
__index = function(table, key)
Expand All @@ -104,10 +108,10 @@ local metatable = {
__newindex = function(table, key, value)
if key == "cursor_color" then
cursor_color = value
set_hl_groups()
M.set_hl_groups()
elseif key == "normal_bg" then
normal_bg = value
set_hl_groups()
M.set_hl_groups()
else
rawset(table, key, value)
end
Expand Down
1 change: 0 additions & 1 deletion lua/smear_cursor/events.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local animation = require("smear_cursor.animation")
local config = require("smear_cursor.config")
local logging = require("smear_cursor.logging")
local screen = require("smear_cursor.screen")
local M = {}

Expand Down
4 changes: 3 additions & 1 deletion lua/smear_cursor/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local color = require("smear_cursor.color")
local config = require("smear_cursor.config")
local draw = require("smear_cursor.draw")
local events = require("smear_cursor.events")
local M = {}

Expand Down Expand Up @@ -37,6 +36,9 @@ local metatable = {
end
elseif key == "cursor_color" or key == "normal_bg" then
color[key] = value
elseif key == "legacy_computing_symbols_support" then
config.legacy_computing_symbols_support = value
color.set_hl_groups()
elseif config[key] ~= nil then
config[key] = value
else
Expand Down
1 change: 0 additions & 1 deletion lua/smear_cursor/screen.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local logging = require("smear_cursor.logging")
local M = {}

M.get_screen_cursor_position = function()
Expand Down

0 comments on commit 0a487dc

Please sign in to comment.