CI: add Makefile target to verify default highlighting groups are present
Commit:
https://github.com/vim/vim/commit/6a15942bc275dc59814f44064e2984b831f7a03d
Author: Christ van Willegen <[email protected]>
Date: Fri Feb 21 20:23:26 2025 +0100
CI: add Makefile target to verify default highlighting groups are present
When adding new highlight groups, one needs to make sure to also add a
"default link NewHlGroup ExistingHlGroup" in highlight.c code, so that
when resetting a color scheme the old color won't be left behind.
So add a Makefile in the 'ci' directory that verifies that all
documented '*hl-<groupname>' from the documentation are either reflected
in the source code, or belong to a list of 'known to be ignored'
highlight groups and let that check run as part of the CI test suite.
related: #16676
closes: #16678
Signed-off-by: Christ van Willegen <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a4eccf07f..2dbf922c5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -96,6 +96,13 @@ jobs:
# exit with an error code and list the missing entries.
make -f ci/unlisted.make
+ - name: Check hlgroups (are any new hlgroups added, but not handled in
highlight.c)
+ run: |
+ # If any highlight groups have been documented, but not handled in
+ # highlight.c, nor listed as 'intentionally left out' in
hlgroups.ignore,
+ # exit with an error code and list the missing entries.
+ make -C ci -f hlgroups.make
+
- run: sudo dpkg --add-architecture i386
if: matrix.architecture == 'i386'
diff --git a/Filelist b/Filelist
index 22a987c4d..07560e5db 100644
--- a/Filelist
+++ b/Filelist
@@ -1148,6 +1148,8 @@ IGNORE = \
.github/workflows/label.yml \
SECURITY.md \
ci/unlisted.make \
+ ci/hlgroups.make \
+ ci/hlgroups.ignore \
src/libvterm/CODE-MAP \
runtime/syntax/testdir/input/html_html \
diff --git a/ci/hlgroups.ignore b/ci/hlgroups.ignore
new file mode 100644
index 000000000..41e06f1bd
--- /dev/null
+++ b/ci/hlgroups.ignore
@@ -0,0 +1,66 @@
+ColorColumn
+ComplMatchIns
+Conceal
+Cursor
+CursorColumn
+CursorIM
+CursorLine
+CursorLineNr
+debugBreakpoint
+debugPC
+DiffAdd
+DiffChange
+DiffDelete
+DiffText
+Directory
+ErrorMsg
+FoldColumn
+Folded
+Ignore
+IncSearch
+lCursor
+LineNr
+LineNrAbove
+LineNrBelow
+MatchParen
+Menu
+ModeMsg
+MoreMsg
+MsgArea
+NonText
+Normal
+Pmenu
+PmenuSbar
+PmenuSel
+PmenuThumb
+Question
+Scrollbar
+Search
+SignColumn
+SpecialKey
+SpellBad
+SpellCap
+SpellLocal
+SpellRare
+StatusLine
+StatusLineNC
+StatusLineTerm
+StatusLineTermNC
+TabLine
+TabLineFill
+TabLineSel
+Terminal
+Title
+TOhtmlProgress
+TOhtml-progress-color
+ToolbarButton
+ToolbarLine
+Tooltip
+User1
+User1..9
+User9
+VertSplit
+Visual
+VisualNOS
+WarningMsg
+WildMenu
diff --git a/ci/hlgroups.make b/ci/hlgroups.make
new file mode 100644
index 000000000..65b39a8c1
--- /dev/null
+++ b/ci/hlgroups.make
@@ -0,0 +1,18 @@
+# vim: ft=make
+SHELL = /bin/bash
+
+# Default target to actually run the comparison:
+.PHONY: check
+.INTERMEDIATE: hlgroups deflinks hlgroups.stripped
+
+check: hlgroups.stripped deflinks
+ diff hlgroups.stripped deflinks
+
+hlgroups:
+ grep '\*hl-' ../runtime/doc/*txt | sed -E -e 's/.*:<?\s*//' -e
's/hl-//g' -e 's/\*//g' -e 's/ /
/g' | sort > hlgroups
+
+deflinks: ../src/highlight.c
+ grep '"default link' $< | sed 's/.*default link\s*\(.*\)\s.*/ /' |
sort > deflinks
+
+hlgroups.stripped: hlgroups.ignore hlgroups
+ grep -v -x -F -f hlgroups.ignore hlgroups > hlgroups.stripped
diff --git a/ci/unlisted.make b/ci/unlisted.make
index 04dfcb53f..6d506eb79 100644
--- a/ci/unlisted.make
+++ b/ci/unlisted.make
@@ -21,7 +21,7 @@ $(eval all_patterns := $(shell \
p; \
}'))
-# In Makefile's `prepeare` target, all the IN_README_DIR files are moved from
+# In Makefile's `prepare` target, all the IN_README_DIR files are moved from
# READMEdir to the root, so add those files in their Git-tracked location:
all_patterns := $(all_patterns) \
$(foreach readme, $(IN_README_DIR), READMEdir/$(readme))
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1tlYir-004yrc-9P%40256bit.org.