diff --git a/compiler/vlty.vim b/compiler/vlty.vim index 2729b6e8bd..1c349fb041 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -71,39 +71,42 @@ if !exists('s:vlty.language') \ 'prompt': 'Multiple spelllang languages detected, please select one:', \ 'abort': v:false, \}) - let s:vlty.language = substitute(s:vlty.language, '_', '-', '') -endif - -if !exists('s:list') - silent let s:list = split( - \ system(s:vlty_lt_command . ' --list NOFILE'), - \ '[[:space:]]') -endif -if !empty(s:list) - if match(s:list, '\c^' . s:vlty.language . '$') == -1 - echohl WarningMsg - echomsg "Language '" . s:vlty.language . "'" - \ . " not listed in output of " - \ . s:vlty_lt_command . " --list!" - let s:vlty.language = matchstr(s:vlty.language, '\v^[^-]+') - echomsg "Trying '" . s:vlty.language . "' instead." - echohl None - if match(s:list, '\c^' . s:vlty.language . '$') == -1 - echoerr "Language '" . s:vlty.language . "'" - \ . " not listed in output of " - \ . s:vlty_lt_command . " --list; trying anyway!" - endif - endif endif -if !empty(s:vlty.language) - let s:vlty_language = ' --language ' . s:vlty.language -else +if empty(s:vlty.language) echohl WarningMsg echomsg 'Please set g:vimtex_grammar_vlty.language to enable more accurate' echomsg 'checks by LanguageTool. Reverting to --autoDetect.' echohl None let s:vlty_language = ' --autoDetect' +else + let s:vlty.language = substitute(s:vlty.language, '_', '-', '') + let s:vlty_language = ' --language ' . s:vlty.language + if !exists('s:list') + silent let s:list = split( + \ system(s:vlty_lt_command . ' --list NOFILE'), + \ '[[:space:]]') + endif + if !empty(s:list) + if match(s:list, '\c^' . s:vlty.language . '$') == -1 + echohl WarningMsg + echomsg "Language '" . s:vlty.language . "'" + \ . " not listed in output of the command " + \ . "'" . s:vlty_lt_command . " --list'! " + \ . "Please check its output!" + echohl None + if match(s:vlty.language, '-') != -1 + let s:vlty.language = matchstr(s:vlty.language, '\v^[^-]+') + echohl WarningMsg + echomsg "Trying '" . s:vlty.language . "' instead." + echohl None + else + echohl WarningMsg + echomsg "Trying '" . s:vlty.language . "' anyway." + echohl None + endif + endif + endif endif let &l:makeprg =