From 8072920019d35ab54bc5d2096a7337cda2799422 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'spellcheck.lua') diff --git a/spellcheck.lua b/spellcheck.lua index a01170f..4a2a9df 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,16 @@ 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, vis, '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