From b559ff646b4dd79034956d4fbf9c2ea3ae2d8df9 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 28 Dec 2022 13:34:45 +0100 Subject: [PATCH] vim:aesth:highNonASCII: Support multi-spelllang `&spelllang` can be a list of multiple languages. Support that by matching the language at the start, the end and/or between commas, instead of comparing the value, and then appending to `l:ignore_chars` for every matched language. --- .config/vim/vimrc.d/50-aesthetics.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.config/vim/vimrc.d/50-aesthetics.vim b/.config/vim/vimrc.d/50-aesthetics.vim index dc1441b..cca4f7e 100644 --- a/.config/vim/vimrc.d/50-aesthetics.vim +++ b/.config/vim/vimrc.d/50-aesthetics.vim @@ -58,12 +58,15 @@ function! HighlightNonASCIIChars() if exists('w:non_ascii_match_id') call matchdelete(w:non_ascii_match_id) endif + let l:ignore_chars = '\d0-\d127' - if (&spelllang == 'de') + if (match(&spelllang, '\v(^|,)de($|,)') != -1) let l:ignore_chars ..= 'äöüß' - elseif (&spelllang == 'fr') + endif + if (match(&spelllang, '\v(^|,)fr($|,)') != -1) let l:ignore_chars ..= 'àâæçèéêëîïôùûüœÀÂÆÇÈÉÊËÎÏÔÙÛÜŒ' endif + let w:non_ascii_match_id = matchadd('NonASCIIChars', \ '[^' .. l:ignore_chars .. ']') endfunction