From 313873704112d53dbbc5975768c8a9adb916c515 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 24 May 2024 14:57:53 +0200 Subject: do not break if lua-lpeg and thus the lexers table is absent --- spellcheck.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/spellcheck.lua b/spellcheck.lua index 0641b45..3062d5c 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -39,11 +39,20 @@ spellcheck.typo_style = 'fore:red' spellcheck.check_full_viewport = {} spellcheck.disable_syntax_awareness = false -spellcheck.check_tokens = { - [vis.lexers.STRING] = true, - [vis.lexers.COMMENT] = true, - [vis.lexers.DEFAULT] = true, -} +-- Only use tokens for spellchecking if they are available. +-- If vis is used in setups without lua-lpeg the lexer tokens are not available. +if vis.lexers then + spellcheck.check_tokens = {} + if vis.lexers.STRING then + spellcheck.check_tokens[vis.lexers.STRING] = true + end + if vis.lexers.COMMENT then + spellcheck.check_tokens[vis.lexers.COMMENT] = true + end + if vis.lexers.DEFAULT then + spellcheck.check_tokens[vis.lexers.DEFAULT] = true + end +end -- Return nil or a sequence of misspelled words in a specific file range or text -- by calling the spellchecker's list command. -- cgit v1.2.3