@@ -346,14 +346,18 @@ local function set_up_highlight(icon_data)
346
346
end
347
347
end
348
348
349
- local nvim_get_hl_by_name = vim .api .nvim_get_hl_by_name
350
349
local function highlight_exists (group )
351
350
if not group then
352
351
return
353
352
end
354
353
355
- local ok , hl = pcall (nvim_get_hl_by_name , group , true )
356
- return ok and not (hl or {})[true ]
354
+ if vim .fn .has " nvim-0.9" == 1 then
355
+ local hl = vim .api .nvim_get_hl (0 , { name = group , link = false })
356
+ return not vim .tbl_isempty (hl )
357
+ else
358
+ local ok , hl = pcall (vim .api .nvim_get_hl_by_name , group , true ) --- @diagnostic disable-line : deprecated
359
+ return ok and not (hl or {})[true ]
360
+ end
357
361
end
358
362
359
363
function M .set_up_highlights (allow_override )
@@ -377,15 +381,31 @@ local function get_highlight_foreground(icon_data)
377
381
icon_data = default_icon
378
382
end
379
383
380
- return string.format (" #%06x" , nvim_get_hl_by_name (get_highlight_name (icon_data ), true ).foreground )
384
+ local higroup = get_highlight_name (icon_data )
385
+
386
+ local fg
387
+ if vim .fn .has " nvim-0.9" == 1 then
388
+ fg = vim .api .nvim_get_hl (0 , { name = higroup , link = false }).fg
389
+ else
390
+ fg = vim .api .nvim_get_hl_by_name (higroup , true ).foreground --- @diagnostic disable-line : deprecated
391
+ end
392
+
393
+ return string.format (" #%06x" , fg )
381
394
end
382
395
383
396
local function get_highlight_ctermfg (icon_data )
384
397
if not global_opts .color_icons then
385
398
icon_data = default_icon
386
399
end
387
400
388
- return nvim_get_hl_by_name (get_highlight_name (icon_data ), false ).foreground
401
+ local higroup = get_highlight_name (icon_data )
402
+
403
+ if vim .fn .has " nvim-0.9" == 1 then
404
+ --- @diagnostic disable-next-line : undefined-field vim .api .keyset .hl_info specifies cterm , not ctermfg
405
+ return vim .api .nvim_get_hl (0 , { name = higroup , link = false }).ctermfg
406
+ else
407
+ return vim .api .nvim_get_hl_by_name (higroup , false ).foreground --- @diagnostic disable-line : deprecated
408
+ end
389
409
end
390
410
391
411
local loaded = false
0 commit comments