aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/highlight_spec.lua
Commit message (Collapse)AuthorAge
* test: simplify functional test expectationsLewis Russell2026-10-05
| | | | | | | | | | | | Problem: Repeated default fields and field-by-field assertions obscure the values that each functional test is meant to check. Solution: Add eq_partial() to check selected record fields while preserving list length and order. Use local helpers to fill fixed expected defaults where tests need full equality. Keep explicit absence checks and test-specific values at the call sites. AI-assisted
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* fix(api): keep highlight font through set/get and redraws #40200glepnir2026-06-15
| | | | | | | | | | | | Problem: a font set via nvim_set_hl is lost or corrupted with font-only groups, attribute combining, and update=true, and is dropped on any attr-table rebuild. nvim__inspect_cell also frees the font name while a returned dict still borrows it. Solution: register font-only groups, carry font through hl_combine_attr, inherit it on update, and persist sg_font so a rebuild can restore it. Keep interned font names across a rebuild instead of clearing them. Add the missing font field to get_hl_info. Co-authored-by: Ryan Patterson <cgamesplay@cgamesplay.com>
* fix(api): expose fg_indexed/bg_indexed in nvim_get_hl #39210glepnir2026-04-20
| | | | | | | | | 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.
* fix(lsp): limit number of created highlight groups (#39133)Evgeni Chasnovski2026-04-17
| | | | | | | | | | | | | | | | | | | | | | | | * fix(api): allow silencing "Too many highlight groups" error Problem: Using Lua's `vim.api.nvim_set_hl(0, 'New', {...})` can fail if there are too many existing highlight groups. However, this error can not be silenced with `pcall`. Solution: Make it possible to silence in `nvim_set_hl` and `nvim_get_hl_id_by_name`. * fix(lsp): limit number of groups created by `document_color()` Problem: A file can contain many string colors that would be highlighted by an LSP server. If this number crosses 19999 (maximum number of allowed highlight groups), there are general issues with creating other highlight groups, which can break functionality outside of `vim.lsp.document_color`. Solution: Limit number of highlight groups that are created by `vim.lsp.document_color` to 10000 (half of allowed maximum). This is not a 100% solution (since there can exist more than 10000 other highlight groups), but explicitly checking number of groups is slow and 10000 should (hopefully) be enough for most use cases.
* feat(api): nvim_set_hl can set "font" #37668glepnir2026-04-12
| | | | | | Problem: Cannot set highlight group fonts via API, only via :highlight command. Solution: Add font parameter in nvim_set_hl().
* fix(api): nvim_get_hl drops groups defined with link_global #38492glepnir2026-04-12
| | | | | | | | | Problem: hlgroup2dict passes &ns_id to ns_get_hl twice. The first call (link=true) sets *ns_hl = 0 when link_global is set, so the second call and the sg_cleared guard both see ns_id == 0 and bail out. The group is silently dropped from the result. Solution: use a temporary copy of ns_id for each ns_get_hl call so the original value is preserved.
* fix(highlight): preserve inherited colors when update=true breaks links #38750glepnir2026-04-11
| | | | | | | Problem: Breaking a link with update=true loses colors inherited from the linked group. Solution: Copy color indices from the linked group so inherited colors remain visible in :hi output.
* docs: news #38464Justin M. Keyes2026-03-28
|
* fix(api): nvim_set_hl boolean false corrupts underline styles (#38504)glepnir2026-03-28
| | | | | | | | | | Problem: setting one underline style to false clears bits belonging to another style. `{underdouble = true, underdashed = false}` results in undercurl because CHECK_FLAG_WITH_KEY does `m &= ~flag` which doesn't work for multi-bit encoded values sharing HL_UNDERLINE_MASK. Solution: use a local variable to derive the correct clear mask from the flag. Clear the whole HL_UNDERLINE_MASK field instead of individual bits, and only clear on false when the current style actually matches.
* feat(api): nvim_set_hl{update:boolean} #37546glepnir2026-03-25
| | | | | | | Problem: nvim_set_hl always replaces all attributes. Solution: Add update field. When true, merge with existing attributes instead of replacing. Unspecified attributes are preserved. If highlight group doesn't exist, falls back to reset mode.
* fix(api): use standard error messagesJustin M. Keyes2026-03-16
|
* fix(api): nvim_set_hl crashes when url= key is passedglepnir2026-03-06
| | | | | | | Problem: Calling nvim_set_hl() with url= crashes because it tries to free arena-owned string memory. Solution: Remove the bad free and return a validation error instead.
* feat(highlight): support more SGR attributes #37901Riccardo Mazzarini2026-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: TUI does not support several standard SGR text attributes: - dim/faint (SGR 2) - blink (SGR 5) - conceal (SGR 8) - overline (SGR 53) This means that when a program running in the embedded terminal emits one of these escape codes, we drop it and don't surface it to the outer terminal. Solution: - Add support for those attributes. - Also add corresponding flags to `nvim_set_hl` opts, so users can set these attributes in highlight groups. - refactor(highlight): widen `HlAttrFlags` from `int16_t` to `int32_t` Widen the `rgb_ae_attr` and `cterm_ae_attr` fields in HlAttrs from int16_t to int32_t to make room for new highlight attribute flags, since there was only one spare bit left. - The C flag is named HL_CONCEALED to avoid colliding with the existing HL_CONCEAL in syntax.h (which is a syntax group flag, not an SGR attribute). - Also note that libvterm doesn't currently support the dim and overline attributes, so e.g. `printf '\e[2mThis should be dim\n'` and `printf '\e[53mThis should have an overline\n'` are still not rendered correctly when run from the embedded terminal.
* fix(highlight): setting 'winhl' doesn't work with global ns (#37868)zeertzjq2026-02-15
| | | | | | Problem: Setting 'winhighlight' doesn't after setting global namespace using nvim_win_set_hl_ns(). Solution: Check if using another namespace when setting 'winhighlight' instead of disabling 'winhighlight' in nvim_win_set_hl_ns().
* test: move deprecated highlight API tests #37801glepnir2026-02-10
| | | | | Problem: Tests for deprecated highlight API were mixed with current API tests. Solution: Move them to deprecated_spec.lua and update highlight_spec.lua to use nvim_get_hl.
* fix(api): make `nvim_set_hl()` respect all `cterm` attributes (#31390)Evgeni Chasnovski2024-12-02
|
* fix(highlight): 'winhl' shouldn't take priority over API (#31288)zeertzjq2024-11-22
|
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: normalise nvim bridge functionsLewis Russell2024-01-12
| | | | | - remove helpers.cur*meths - remove helpers.nvim
* test: typing for helpers.methsLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* feat(highlight): update default color schemeEvgeni Chasnovski2023-12-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Default color scheme is suboptimal. Solution: Start using new color scheme. Introduce new `vim` color scheme for opt-in backward compatibility. ------ Main design ideas - Be "Neovim branded". - Be minimal for 256 colors with a bit more shades for true colors. - Be accessible through high enough contrast ratios. - Be suitable for dark and light backgrounds via exchange of dark and light palettes. ------ Palettes - Have dark and light variants. Implemented through exporeted `NvimDark*` and `NvimLight*` hex colors. - Palettes have 4 shades of grey for UI elements and 6 colors (red, yellow, green, cyan, blue, magenta). - Actual values are computed procedurally in Oklch color space based on a handful of hyperparameters. - Each color has a 256 colors variant with perceptually closest color. ------ Highlight groups Use: - Grey shades for general UI according to their design. - Bold text for keywords (`Statement` highlight group). This is an important choice to increase accessibility for people with color deficiencies, as it doesn't rely on actual color. - Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some minor text UI elements. - Cyan as main syntax color, i.e. for function usage (`Function` highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI elements. - Red to generally mean high user attention, i.e. errors; in particular for `ErrorMsg`, `DiffDelete`, `DiagnosticError`. - Yellow very sparingly only with true colors to mean mild user attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`. - Blue very sparingly only with true colors as `DiagnosticHint` and some additional important syntax group (like `Identifier`). - Magenta very carefully (if at all). ------ Notes - To make tests work without relatively larege updates, each one is prepended with an equivalent of the call `:colorscheme vim`. Plus some tests which spawn new Neovim instances also now use 'vim' color scheme. In some cases tests are updated to fit new default color scheme.
* feat(ui): allow to get the highlight namespaceDaniel Steinberg2023-10-01
|
* fix(highlight): add force in nvim_set_hlglepnir2023-09-26
|
* fix(highlight): correct hi command outputglepnir2023-09-17
|
* fix(highlight): add create param in nvim_get_hlglepnir2023-09-09
|
* refactor(api): use typed keysetsbfredl2023-08-07
| | | | | Initially this is just for geting rid of boilerplate, but eventually the types could get exposed as metadata
* fix(api): nvim_get_hl should return default flagNull Chilly2023-05-22
|
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* fix(api): make nvim_get_hl not return non-existing groupsbfredl2023-04-13
| | | | fixes #23063
* fix(api): return both link and attributes with nvim_get_hl (#22824)Sindre T. Strøm2023-03-31
| | | | | Problem: No way to get the actual highlight attributes for a linked group through |nvim_get_hl()| (not the attributes from the link target). Solution: Return the actual attributes as well as the link target name.
* fix(api): make nvim_get_hl return 'cterm' attrs properlybfredl2023-03-23
|
* feat(api): add nvim_get_hl (#22693)Null Chilly2023-03-23
| | | | | Problem: no way of getting all highlight group definitions in a namespace. Solution: add `nvim_get_hl()`, deprecate `nvim_get_hl_by_name()` and `nvim_get_hl_by_id()`.
* fix(highlight): avoid ORing underline flags (#22372)zeertzjq2023-02-23
| | | | | When combining attributes use the one that takes priority. For :highlight command use the last one specified. For API use a hard-coded order same as the order in docs.
* refactor(api): consistent VALIDATE messages #22262Justin M. Keyes2023-02-14
| | | | | | | | | | Problem: Validation messages are not consistently formatted. - Parameter names sometimes are NOT quoted. - Descriptive names (non-parameters) sometimes ARE quoted. Solution: Always quote the `name` value passed to a VALIDATE macro _unless_ the value has whitespace.
* refactor(api): VALIDATE macros #22256Justin M. Keyes2023-02-14
| | | | | | - VALIDATE() takes a format string - deduplicate check_string_array - VALIDATE_RANGE - validate UI args
* fix(highlight): properly deal with underline mask when listing (#22057)zeertzjq2023-01-31
|
* feat(highlight): define the concept of altfont as a (c)term rendering attributePaul "LeoNerd" Evans2023-01-24
|
* refactor(highlight): reshape the HL_UNDER* bits into a 3-bit integer maskPaul "LeoNerd" Evans2023-01-24
| | | | Saves two bits for reuse for new features
* fix(tests): initialize Screen.colors in API highlight testsJon Huhn2022-12-10
|
* fix(api): nvim_set_hl bail out on invalid group name (#20021)zeertzjq2022-08-31
|
* feat(ui): allow to set the highlight namespace per windowbfredl2022-08-17
| | | | | - reimplement 'winhl' in terms of highlight namespaces - check for EOF in screen tests (to indicate a likely crash)
* fix(highlight): add missing 'nocombine' to nvim_get_hl_* apis (#19586)Munif Tanjim2022-07-31
|
* refactor(highlight)!: rename attributes to match Vim (#19159)zeertzjq2022-06-30
| | | | | | | | | Ref: https://github.com/vim/vim/commit/84f546363068e4ddfe14a8a2a2322bb8d3a25417 Rename: - `underlineline` to `underdouble` - `underdot` to `underdotted` - `underdash` to `underdashed` `underdouble` also now takes higher precedence than `undercurl`.
* perf(highlight): don't allocate duplicates for color namesbfredl2022-06-21
|
* fix(hl): return cterm fg/bg even if they match Normal #18981Oliver Marriott2022-06-16
| | | | | | | | | | Fixes #18980 - 831fa45ad84e is related but this doesn't regress that - The `cterm_normal_fg_color != ae.cterm_fg_color` comparison is originally carried from patch to patch starting all the way back in 29bc6dfabde2 where it was avoiding setting a HL attr. But `hlattrs2dict()` now is just informational.