aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-05-24 14:57:53 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2024-05-24 14:57:53 +0200
commit313873704112d53dbbc5975768c8a9adb916c515 (patch)
tree89988a417eac31594d61dd10294f5aebd8f53843
parent41d2f76bbd4ef98de68b43966d07f3bf37b82b69 (diff)
downloadvis-spellcheck-313873704112d53dbbc5975768c8a9adb916c515.tar.gz
vis-spellcheck-313873704112d53dbbc5975768c8a9adb916c515.zip
do not break if lua-lpeg and thus the lexers table is absent
-rw-r--r--spellcheck.lua19
1 files 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.