@@ -18,8 +18,22 @@ function ColoredPrinter:get_256_color(index)
1818 -- Standard 16 colors (0-15)
1919 if index <= 15 then
2020 local colors = {
21- " #000000" , " #800000" , " #008000" , " #808000" , " #000080" , " #800080" , " #008080" , " #c0c0c0" ,
22- " #808080" , " #ff0000" , " #00ff00" , " #ffff00" , " #0000ff" , " #ff00ff" , " #00ffff" , " #ffffff"
21+ " #000000" ,
22+ " #800000" ,
23+ " #008000" ,
24+ " #808000" ,
25+ " #000080" ,
26+ " #800080" ,
27+ " #008080" ,
28+ " #c0c0c0" ,
29+ " #808080" ,
30+ " #ff0000" ,
31+ " #00ff00" ,
32+ " #ffff00" ,
33+ " #0000ff" ,
34+ " #ff00ff" ,
35+ " #00ffff" ,
36+ " #ffffff" ,
2337 }
2438 return colors [index + 1 ]
2539 end
@@ -30,12 +44,14 @@ function ColoredPrinter:get_256_color(index)
3044 local r = math.floor (n / 36 )
3145 local g = math.floor ((n % 36 ) / 6 )
3246 local b = n % 6
33-
47+
3448 local function color_value (c )
35- if c == 0 then return 0 end
49+ if c == 0 then
50+ return 0
51+ end
3652 return 55 + c * 40
3753 end
38-
54+
3955 return string.format (" #%02x%02x%02x" , color_value (r ), color_value (g ), color_value (b ))
4056 end
4157
@@ -78,7 +94,7 @@ function ColoredPrinter:setup_highlight_groups()
7894 -- Add background color groups (40-47, 100-107)
7995 local bg_colors = {
8096 [" 40" ] = " Black" ,
81- [" 41" ] = " Red" ,
97+ [" 41" ] = " Red" ,
8298 [" 42" ] = " Green" ,
8399 [" 43" ] = " Yellow" ,
84100 [" 44" ] = " Blue" ,
@@ -87,7 +103,7 @@ function ColoredPrinter:setup_highlight_groups()
87103 [" 47" ] = " White" ,
88104 [" 100" ] = " Grey" ,
89105 [" 101" ] = " Red" ,
90- [" 102" ] = " Green" ,
106+ [" 102" ] = " Green" ,
91107 [" 103" ] = " Yellow" ,
92108 [" 104" ] = " Blue" ,
93109 [" 105" ] = " Magenta" ,
@@ -98,7 +114,7 @@ function ColoredPrinter:setup_highlight_groups()
98114 for code , color in pairs (bg_colors ) do
99115 local group_name = " QuicktestAnsiBgColor_" .. code
100116 vim .cmd (string.format (" highlight %s ctermbg=%s guibg=%s" , group_name , color :lower (), color ))
101-
117+
102118 self .color_groups [code ] = group_name
103119 end
104120
@@ -179,6 +195,7 @@ function ColoredPrinter:get_or_create_color_group(fg, bg, styles)
179195 end
180196
181197 if start_cmd ~= cmd then
198+ --- @diagnostic disable-next-line : param-type-mismatch
182199 local success , err = pcall (vim .cmd , cmd )
183200 if not success then
184201 -- Fallback to basic highlight if command fails
@@ -246,32 +263,44 @@ function ColoredPrinter:parse_colors(line)
246263 elseif code == 21 then
247264 table.insert (self .current_styles , " undercurl" )
248265 elseif code == 22 then
249- self .current_styles = vim .tbl_filter (function (s ) return s ~= " bold" end , self .current_styles )
266+ self .current_styles = vim .tbl_filter (function (s )
267+ return s ~= " bold"
268+ end , self .current_styles )
250269 -- Reset dim color if it was set
251270 if self .current_fg == " #808080" then
252271 self .current_fg = nil
253272 end
254273 elseif code == 23 then
255- self .current_styles = vim .tbl_filter (function (s ) return s ~= " italic" end , self .current_styles )
274+ self .current_styles = vim .tbl_filter (function (s )
275+ return s ~= " italic"
276+ end , self .current_styles )
256277 elseif code == 24 then
257- self .current_styles = vim .tbl_filter (function (s ) return s ~= " underline" and s ~= " undercurl" end , self .current_styles )
278+ self .current_styles = vim .tbl_filter (function (s )
279+ return s ~= " underline" and s ~= " undercurl"
280+ end , self .current_styles )
258281 elseif code == 25 then
259282 -- Reset blink (not supported anyway)
260283 elseif code == 27 then
261- self .current_styles = vim .tbl_filter (function (s ) return s ~= " reverse" end , self .current_styles )
284+ self .current_styles = vim .tbl_filter (function (s )
285+ return s ~= " reverse"
286+ end , self .current_styles )
262287 elseif code == 28 then
263288 -- Reset conceal (not supported anyway)
264289 elseif code == 29 then
265- self .current_styles = vim .tbl_filter (function (s ) return s ~= " strikethrough" end , self .current_styles )
290+ self .current_styles = vim .tbl_filter (function (s )
291+ return s ~= " strikethrough"
292+ end , self .current_styles )
266293 elseif code == 39 then
267- self .current_fg = nil -- Reset foreground to default
294+ self .current_fg = nil -- Reset foreground to default
268295 -- If bold was auto-added by bright color, remove it
269296 if self .bright_color_bold then
270- self .current_styles = vim .tbl_filter (function (s ) return s ~= " bold" end , self .current_styles )
297+ self .current_styles = vim .tbl_filter (function (s )
298+ return s ~= " bold"
299+ end , self .current_styles )
271300 self .bright_color_bold = false
272301 end
273302 elseif code == 49 then
274- self .current_bg = nil -- Reset background to default
303+ self .current_bg = nil -- Reset background to default
275304 elseif code >= 30 and code <= 37 then
276305 self .current_fg = tostring (code )
277306 elseif code >= 40 and code <= 47 then
0 commit comments