diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2025-02-24 18:59:10 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-03-10 16:13:45 -0300 |
| commit | 9f30c87b5b687118f4e0c88249ca08ebad2f3003 (patch) | |
| tree | f30cf9b9482faa531e1da671350e22df871a6748 /spellcheck.lua | |
| parent | 5f11dae4b32ae288951bda63e4936815ec2e4087 (diff) | |
| download | vis-spellcheck-9f30c87b5b687118f4e0c88249ca08ebad2f3003.tar.gz vis-spellcheck-9f30c87b5b687118f4e0c88249ca08ebad2f3003.zip | |
feat: automatically enable spellchecking through local setting
When the local setting spellcheck.spelling_autoenable is set to
true and spelling is available (via `spelling_language` setting
in .editorconfig), vis will automatically enable spellchecker
without any additional user action.
References: https://github.com/editorconfig/specification/pull/41
Diffstat (limited to 'spellcheck.lua')
| -rw-r--r-- | spellcheck.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spellcheck.lua b/spellcheck.lua index 3737a3e..fd8d0fe 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -6,6 +6,8 @@ if not spellcheck.default_lang:match('^[a-z][a-z]_[A-Z][A-Z]$') then spellcheck.default_lang = 'en_US' end +spellcheck.spelling_autoenable = false + spellcheck.get_lang = function() if vis.win.file.spelling_language then return vis.win.file.spelling_language @@ -304,6 +306,12 @@ vis:map(vis.modes.NORMAL, '<C-w>e', function() enable_spellcheck() end, 'Enable spellchecking in the current window') +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + if vis.win.file.spelling_language and spellcheck.spelling_autoenable then + enable_spellcheck() + end +end) + local disable_spellcheck = function() local old_lex_func = wrapped_lex_funcs[vis.win] if old_lex_func then |
