diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-08-18 14:23:04 +0100 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2022-08-24 17:13:18 +0100 |
commit | 61be343ec8c5e4d504db7ba975b20af2f46ce50d (patch) | |
tree | b0f3d20a955afaacb5d48a9579612f4e41678e59 /src/nvim/highlight_group.c | |
parent | a4e4609d62c38b7b949e5c8079dfa5f10803bdcd (diff) | |
download | rneovim-61be343ec8c5e4d504db7ba975b20af2f46ce50d.tar.gz rneovim-61be343ec8c5e4d504db7ba975b20af2f46ce50d.tar.bz2 rneovim-61be343ec8c5e4d504db7ba975b20af2f46ce50d.zip |
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 <christian.clason@uni-due.de>
Diffstat (limited to 'src/nvim/highlight_group.c')
-rw-r--r-- | src/nvim/highlight_group.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 04aecc6c3a..ab241516e4 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -1750,11 +1750,11 @@ static int syn_add_group(const char *name, size_t len) if (!vim_isprintc(c)) { emsg(_("E669: Unprintable character in group name")); return 0; - } else if (!ASCII_ISALNUM(c) && c != '_') { - // This is an error, but since there previously was no check only give a warning. + } else if (!ASCII_ISALNUM(c) && c != '_' && c != '.' && c != '@') { + // '.' and '@' are allowed characters for use with treesitter capture names. msg_source(HL_ATTR(HLF_W)); - msg(_("W18: Invalid character in group name")); - break; + emsg(_(e_highlight_group_name_invalid_char)); + return 0; } } |