aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spellcheck.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index a01170f..78ea8b6 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -476,7 +476,7 @@ vis:map(vis.modes.NORMAL, '<C-w>a', function()
return 0
end, 'Add word to user dictionary')
-vis:option_register('spelllang', 'string', function(value)
+local function set_spelllang_option(value)
vis.win.file.spelling_language = value
vis:info('Spellchecking language is now ' .. value)
-- force new highlight for full viewport
@@ -484,7 +484,15 @@ vis:option_register('spelllang', 'string', function(value)
-- force new highlight for syntax aware
last_data = ''
return true
-end, 'The language used for spellchecking')
+end
+
+-- Detect if vis supports the get-callback for option registration
+if not pcall(vis:option_register('spelllang', 'string', set_spelllang_option,
+ spellcheck.get_lang, 'The language used for spellchecking'))
+then
+ vis:option_register('spelllang', 'string', set_spelllang_option,
+ 'The language used for spellchecking')
+end
vis:command_register('spelllang', function()
vis:info('The spellchecking language is ' .. spellcheck.get_lang())