Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support spelling_language property #210

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions plugin/editorconfig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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