diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-05-13 19:25:10 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-05-14 14:11:27 +0200 |
| commit | 8072920019d35ab54bc5d2096a7337cda2799422 (patch) | |
| tree | c19958e82e84e6e3ae6757cd267861f612d1c797 | |
| parent | 21a4efe73aa41a3ffb6442c26bffb59a77a35ee0 (diff) | |
| download | vis-spellcheck-8072920019d35ab54bc5d2096a7337cda2799422.tar.gz vis-spellcheck-8072920019d35ab54bc5d2096a7337cda2799422.zip | |
pass get callback when registering the spelllang option
| -rw-r--r-- | spellcheck.lua | 13 |
1 files changed, 11 insertions, 2 deletions
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, '<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,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()) |
