<commit_before>if exists('current_compiler') | finish | endif
let current_compiler = 'vlty'

" Older Vim always used :setlocal
if exists(':CompilerSet') != 2
  command -nargs=* CompilerSet setlocal <args>
endif

let s:cpo_save = &cpo
set cpo&vim

let s:vlty = g:vimtex_grammar_vlty

function! s:installation_error(msg)
  call vimtex#log#error(
        \ [a:msg, 'Please see ":help vimtex-grammar-vlty" for more details.'])
endfunction

if !executable('python')
  call s:installation_error('vlty compiler requires Python')
  finish
endif

call system('python -c "import yalafi"')
if v:shell_error != 0
  call s:installation_error('vlty compiler requires the Python module YaLafi')
  finish
endif

if s:vlty.server !=# 'lt'
  if !executable('java')
    call s:installation_error('vlty compiler requires java')
    finish
  endif

  if !filereadable(fnamemodify(s:vlty.lt_directory
        \ . '/languagetool-commandline.jar', ':p'))
    call s:installation_error('vlty compiler - lt_directory path not valid')
    finish
  endif
endif

let s:vimtex = get(b:, 'vimtex', {'documentclass': '', 'packages': {}})
let s:documentclass = s:vimtex.documentclass
let s:packages = join(keys(s:vimtex.packages), ',')
let s:language = matchstr(&spelllang, '\v^\a\a([-_]\a\a)?')
let s:language = substitute(s:language, '_', '-', '')

let &l:makeprg =
      \ 'python -m yalafi.shell'
      \ . ' --lt-directory ' . s:vlty.lt_directory
      \ . (s:vlty.server ==# 'no'
      \    ?  ''
      \    : ' --server ' . s:vlty.server)
      \ . ' --language ' . s:language
      \ . ' --disable "' . s:vlty.lt_disable . '"'
      \ . ' --enable "' . s:vlty.lt_enable . '"'
      \ . ' --disablecategories "' . s:vlty.lt_disablecategories . '"'
      \ . ' --enablecategories "' . s:vlty.lt_enablecategories . '"'
      \ . ' --documentclass "' . s:documentclass . '"'
      \ . ' --packages "' . s:packages . '"'
      \ . ' ' . s:vlty.shell_options
      \ . ' %:S'
silent CompilerSet makeprg

let &l:errorformat = '%A%*\d.) Line %l\, column %v\, Rule ID:%.%#,'
if s:vlty.show_suggestions == 0
  let &l:errorformat .= '%ZMessage: %m,%-G%.%#'
else
  let &l:errorformat .= '%CMessage: %m,%Z%m,%-G%.%#'
endif
silent CompilerSet errorformat

let &cpo = s:cpo_save
unlet s:cpo_save<commit_msg>Added file name to errorformat<commit_after>if exists('current_compiler') | finish | endif
let current_compiler = 'vlty'

" Older Vim always used :setlocal
if exists(':CompilerSet') != 2
  command -nargs=* CompilerSet setlocal <args>
endif

let s:cpo_save = &cpo
set cpo&vim

let s:vlty = g:vimtex_grammar_vlty

function! s:installation_error(msg)
  call vimtex#log#error(
        \ [a:msg, 'Please see ":help vimtex-grammar-vlty" for more details.'])
endfunction

if !executable('python')
  call s:installation_error('vlty compiler requires Python')
  finish
endif

call system('python -c "import yalafi"')
if v:shell_error != 0
  call s:installation_error('vlty compiler requires the Python module YaLafi')
  finish
endif

if s:vlty.server !=# 'lt'
  if !executable('java')
    call s:installation_error('vlty compiler requires java')
    finish
  endif

  if !filereadable(fnamemodify(s:vlty.lt_directory
        \ . '/languagetool-commandline.jar', ':p'))
    call s:installation_error('vlty compiler - lt_directory path not valid')
    finish
  endif
endif

let s:vimtex = get(b:, 'vimtex', {'documentclass': '', 'packages': {}})
let s:documentclass = s:vimtex.documentclass
let s:packages = join(keys(s:vimtex.packages), ',')
let s:language = matchstr(&spelllang, '\v^\a\a([-_]\a\a)?')
let s:language = substitute(s:language, '_', '-', '')

let &l:makeprg =
      \ 'python -m yalafi.shell'
      \ . ' --lt-directory ' . s:vlty.lt_directory
      \ . (s:vlty.server ==# 'no'
      \    ?  ''
      \    : ' --server ' . s:vlty.server)
      \ . ' --language ' . s:language
      \ . ' --disable "' . s:vlty.lt_disable . '"'
      \ . ' --enable "' . s:vlty.lt_enable . '"'
      \ . ' --disablecategories "' . s:vlty.lt_disablecategories . '"'
      \ . ' --enablecategories "' . s:vlty.lt_enablecategories . '"'
      \ . ' --documentclass "' . s:documentclass . '"'
      \ . ' --packages "' . s:packages . '"'
      \ . ' ' . s:vlty.shell_options
      \ . ' %:S'
silent CompilerSet makeprg

let &l:errorformat = '%I=== %f ===,%C%*\d.) Line %l\, column %v\, Rule ID:%.%#,'
if s:vlty.show_suggestions == 0
  let &l:errorformat .= '%ZMessage: %m,%-G%.%#'
else
  let &l:errorformat .= '%CMessage: %m,%Z%m,%-G%.%#'
endif
silent CompilerSet errorformat

let &cpo = s:cpo_save
unlet s:cpo_save
{'fraction_non_alphanumeric': 0.17900964066608238, 'fraction_numerical': 0.0013146362839614374, 'mean_word_length': 3.207373271889401, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '461232', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1659, 'n_words': 353}