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-13 19:25:10 +0200 |
| commit | 68d5066a55fa9349c25752128782aa2575778596 (patch) | |
| tree | 32cecfe29434f8a1097e91cdf4a8eef566838311 | |
| parent | 21a4efe73aa41a3ffb6442c26bffb59a77a35ee0 (diff) | |
| download | vis-spellcheck-get-option-callback.tar.gz vis-spellcheck-get-option-callback.zip | |
pass get callback when registering the spelllang optionget-option-callback
| -rw-r--r-- | spellcheck.lua | 12 |
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()) |
