From 61be343ec8c5e4d504db7ba975b20af2f46ce50d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 18 Aug 2022 14:23:04 +0100 Subject: feat(highlight)!: error on invalid names and allow '.' and '@' Previously if a highlight group with a name outside the regexp [a-zA-Z0-9_] was defined, Nvim would emit an "invalid character" warning message. This was annoying for Lua scripts, as it was very hard to debug what line of code was triggering this message since it didn't produce a stack trace. This has now been promoted to an error with the code E5248. Additionally the ASCII character period ('.') and at-sign ('@') have been added to the allowed list of characters of a highlight group name to support the application of defining hierarchical highlight groups, e.g. 'TS.keyword'. Co-authored-by: Christian Clason --- runtime/doc/syntax.txt | 10 +++++----- runtime/doc/vim_diff.txt | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index b74611633f..6fcf292513 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -181,16 +181,16 @@ Vim will only load the first syntax file found, assuming that it sets b:current_syntax. -NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18* +NAMING CONVENTIONS *group-name* *{group-name}* *E669* *E5248* A syntax group name is to be used for syntax items that match the same kind of thing. These are then linked to a highlight group that specifies the color. A syntax group name doesn't specify any color or attributes itself. -The name for a highlight or syntax group must consist of ASCII letters, digits -and the underscore. As a regexp: "[a-zA-Z0-9_]*". However, Vim does not give -an error when using other characters. The maximum length of a group name is -about 200 bytes. *E1249* +The name for a highlight or syntax group must consist of ASCII letters, +digits, underscores, periods and `@` characters. As a regexp it is +`[a-zA-Z0-9_.@]*`. The maximum length of a group name is about 200 bytes. +*E1249* To be able to allow each user to pick their favorite set of colors, there must be preferred names for highlight groups that are common for many languages. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 53effa1443..0011cd9821 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -390,6 +390,9 @@ Highlight groups: using |n| or |N| |hl-CursorLine| is low-priority unless foreground color is set |hl-VertSplit| superseded by |hl-WinSeparator| + Highlight groups names are allowed to contain the characters `.` and `@`. + It is an error to define a highlight group with a name that doesn't match + the regexp `[a-zA-Z0-9_.@]*` (see |group-name|). Macro/|recording| behavior Replay of a macro recorded during :lmap produces the same actions as when it -- cgit