diff options
| -rw-r--r-- | Readme.md | 3 | ||||
| -rw-r--r-- | spellcheck.lua | 8 |
2 files changed, 11 insertions, 0 deletions
@@ -26,6 +26,9 @@ The module table returned from `require(...)` has some configuration options: * default: `enchant -l -d %s` * `default_lang`: The name of the used dictionary if the opened file does not specify one. The selected language is inserted in the cmd-strings at `%s`. * default: `$LANG` or `en_US` +* `spelling_autoenable`: Enable automatic enabling of spellchecker when spelling is available + (via `spelling_language` setting in .editorconfig) without any additional user action. + * default: `false` * `typo_style`: The style string with which misspellings should be highlighted when using the _full viewport_ method * default: `fore:red` * `check_tokens`: A table mapping all token names we consider for spellchecking to true 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 |
