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.
This commit is contained in:
2022-12-28 13:34:45 +01:00
parent c2a657c609
commit b559ff646b

View File

@@ -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