From 68d5066a55fa9349c25752128782aa2575778596 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 13 May 2026 19:25:10 +0200 Subject: pass get callback when registering the spelllang option --- spellcheck.lua | 12 ++++++++++-- 1 file 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, '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()) -- cgit v1.2.3