fix(api): expose fg_indexed/bg_indexed in nvim_get_hl #39210

Problem: fg_indexed/bg_indexed were dropped from nvim_get_hl output due
to a wrong short_keys guard. HL_FG_INDEXED also wasn't cleared in
hl_blend_attrs, and HLATTRS_DICT_SIZE was too small.

Solution: Remove the short_keys guard, clear HL_FG_INDEXED in
hl_blend_attrs, bump HLATTRS_DICT_SIZE to 24, and clarify docs that
these flags mean rgb is an approximation of the cterm palette index.
This commit is contained in:
glepnir
2026-04-20 17:12:52 +08:00
committed by GitHub
parent c7d4892ce6
commit 01861c2f95
7 changed files with 50 additions and 24 deletions

View File

@@ -2224,7 +2224,8 @@ function vim.api.nvim_set_decoration_provider(ns_id, opts) end
--- @param val vim.api.keyset.highlight Highlight definition map, accepts the following keys:
--- - altfont: boolean
--- - bg: color name or "#RRGGBB", see note.
--- - bg_indexed: boolean (default false) If true, bg is a terminal palette index (0-255).
--- - bg_indexed: boolean. If true, `bg` is an RGB approximation of `ctermbg`
--- (a palette index). UIs rendering cterm natively may prefer `ctermbg`.
--- - blend: integer between 0 and 100
--- - blink: boolean
--- - bold: boolean
@@ -2236,7 +2237,7 @@ function vim.api.nvim_set_decoration_provider(ns_id, opts) end
--- - default: boolean Don't override existing definition `:hi-default`
--- - dim: boolean
--- - fg: Color name or "#RRGGBB", see note.
--- - fg_indexed: boolean (default false) If true, fg is a terminal palette index (0-255).
--- - fg_indexed: boolean. Same as `bg_indexed`, for `fg` and `ctermfg`.
--- - font: GUI font name (string). Sets `highlight-font`. Use "NONE" to clear.
--- - force: boolean (default false) Update the highlight group even if it already exists.
--- - italic: boolean

View File

@@ -152,13 +152,15 @@ error('Cannot require a meta file')
--- @field background? integer
--- @class vim.api.keyset.get_hl_info : vim.api.keyset.hl_info.base
--- @field fg? integer
--- @field bg? integer
--- @field sp? integer
--- @field default? true
--- @field link? string
--- @field blend? integer
--- @field bg? integer
--- @field bg_indexed? boolean
--- @field cterm? vim.api.keyset.hl_info.cterm
--- @field default? true
--- @field fg? integer
--- @field fg_indexed? boolean
--- @field link? string
--- @field sp? integer
--- @class vim.api.keyset.set_hl_info : vim.api.keyset.hl_info.base
--- @field fg? integer|string