Skip to content

nvim_get_hl_by_name(*, false) wont return cterm values for Normal or groups with the same values as Normal #18980

@rktjmp

Description

@rktjmp

Neovim version (nvim -v)

NVIM v0.8.0-dev+432-gfa4b0c3ba

How to reproduce the issue

-- cterm value tests

-- Set Normal via lua api, get value
vim.api.nvim_set_hl(0, "Normal", {ctermfg = 16, ctermbg = 231})
vim.pretty_print("nvim_set_hl normal", vim.api.nvim_get_hl_by_name("Normal", false))
-- FAIL => {true = 6}

-- Normal group has some special handling sometimes, so check another group
-- but set the values = Normal
vim.api.nvim_set_hl(0, "NotNormal", {ctermfg = 16, ctermbg = 231})
vim.pretty_print("nvim_set_hl not-normal = normal", vim.api.nvim_get_hl_by_name("NotNormal", false))
-- FAIL => {true = 6}

-- Check another group but set values to NOT normal
vim.api.nvim_set_hl(0, "NotNormal", {ctermfg = 61, ctermbg = 132})
vim.pretty_print("nvim_set_hl not-normal", vim.api.nvim_get_hl_by_name("NotNormal", false))
-- OK => {background = 132, foreground = 61}

-- set via classic method
vim.cmd("hi Normal ctermfg=16 ctermbg=231")
vim.pretty_print("hi normal", vim.api.nvim_get_hl_by_name("Normal", false))
-- FAIL => {true = 6}
--
vim.cmd("hi NotNormal ctermfg=16 ctermbg=231")
vim.pretty_print("hi not-normal = normal", vim.api.nvim_get_hl_by_name("NotNormal", false))
-- FAIL => {true = 6}

vim.cmd("hi NotNormal ctermfg=17 ctermbg=18")
vim.pretty_print("hi not-normal", vim.api.nvim_get_hl_by_name("NotNormal", false))
-- OK => {background = 18, foreground = 17}

vim.pretty_print("default comment", vim.api.nvim_get_hl_by_name("Comment", false))
-- OK => {foreground = 14}

See also #18024 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    apilibnvim, Nvim RPC API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions