diff --git a/README.md b/README.md index d25ac18e..a6dae2ec 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The EditorConfig Vim plugin supports the following EditorConfig [properties][]: or [PreserveNoEOL][] is required for this property) * `trim_trailing_whitespace` * `max_line_length` +* `spelling_language` * `root` (only used by EditorConfig core) ## Selected Options diff --git a/plugin/editorconfig.vim b/plugin/editorconfig.vim index 76377269..72ead64d 100644 --- a/plugin/editorconfig.vim +++ b/plugin/editorconfig.vim @@ -586,6 +586,10 @@ function! s:ApplyConfig(bufnr, config) abort endif endif + if s:IsRuleActive('spelling_language', a:config) + let &l:spelllang=s:ConvertLanguage(a:config['spelling_language']) + endif + call editorconfig#ApplyHooks(a:config) endfunction @@ -612,4 +616,16 @@ endfunction "}}}1 let &cpo = s:saved_cpo unlet! s:saved_cpo +" {{{ +function! s:ConvertLanguage(language) + " Only accept xx or xx-YY language codes (as per editorconfig specification) + if a:language =~ '^[a-z]\{2}\(-[A-Z]\{2}\)\?$' + " Convert to vim-style xx_yy + return tolower(substitute(a:language, "-", "_", "")) + elseif g:EditorConfig_verbose + echom "'" . a:language . "'' does not match specification for spelling_language. Try 'en' or 'en-GB'" + return "" + endif +endfunction +" }}} " vim: fdm=marker fdc=3