Skip to content

Commit cfb2639

Browse files
authored
fix: adds ' and " to excluded additional characters (#145)
1 parent 9b5fe04 commit cfb2639

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

lua/colorizer/utils.lua

+9-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ function M.add_additional_color_chars(chars)
9797
local char = chars:sub(i, i)
9898
local char_byte = string.byte(char)
9999
-- It's possible to define `custom_names` with spaces. Ignore space: it's by empty space that separate things may exist 🧘
100-
if char_byte ~= 32 and byte_category[char_byte] == 0 then
100+
if
101+
char_byte ~= 32
102+
and char_byte ~= ("'"):byte()
103+
and char_byte ~= ('"'):byte()
104+
and byte_category[char_byte] == 0
105+
then
101106
additional_color_chars = additional_color_chars .. char
102107
byte_category[char_byte] = 1
103108
end
@@ -235,8 +240,10 @@ end
235240
--- Returns sha256 hash of lua table
236241
---@param tbl table: Table to be hashed
237242
function M.hash_table(tbl)
243+
-- local json_string = vim.json.encode(tbl, { escape_slash = true })
238244
local json_string = vim.json.encode(tbl)
239-
return vim.fn.sha256(json_string)
245+
local hash = vim.fn.sha256(json_string)
246+
return hash
240247
end
241248

242249
return M

test/expect.lua

+20
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ local opts = {
2222
["five@six"] = "#e9e240",
2323
["seven!eight"] = "#a9e042",
2424
["nine!!ten"] = "#09e392",
25+
["'r'"] = "#FF0000",
26+
['"r"'] = "#FF0000",
27+
["'g'"] = "#00FF00",
28+
['"g"'] = "#00FF00",
29+
["'b'"] = "#0000FF",
30+
['"b"'] = "#0000FF",
31+
["'c'"] = "#00FFFF",
32+
['"c"'] = "#00FFFF",
33+
["'m'"] = "#FF00FF",
34+
['"m"'] = "#FF00FF",
35+
["'y'"] = "#FFFF00",
36+
['"y"'] = "#FFFF00",
37+
["'k'"] = "#000000",
38+
['"k"'] = "#000000",
39+
["'w'"] = "#FFFFFF",
40+
['"w"'] = "#FFFFFF",
2541
},
2642
},
2743
},
@@ -101,6 +117,10 @@ From table in filetype definiton (lua)
101117
FIX: .
102118
FIX: fix
103119
120+
'r' 'g' 'b' 'c' 'm' 'y' 'k' 'w'
121+
"r" "g" "b" "c" "m" "y" "k" "w"
122+
r g b c m y k w
123+
104124
Tailwind names:
105125
accent-blue-100 bg-gray-200 border-black border-x-zinc-300 border-y-yellow-400 border-t-teal-500 border-r-neutral-600 border-b-blue-700 border-l-lime-800 caret-indigo-900 decoration-sky-950 divide-white fill-violet-950 from-indigo-900 shadow-blue-800 stroke-sky-700 text-cyan-500 to-red-400 via-green-300 ring-emerald-200 ring-offset-violet-100
106126

0 commit comments

Comments
 (0)