ale icon indicating copy to clipboard operation
ale copied to clipboard

Add support for textidote (LaTeX and Markdown linter)

Open dkasak opened this issue 6 years ago • 2 comments

Name: textidote URL: https://github.com/sylvainhalle/textidote

This is a linter for LaTeX which strips away LaTeX commands, but remembering the original positions of the text. It then passes the text to LanguageTool and can map errors from it back to the correct LaTeX source file locations.

They also recently added support for Markdown.

dkasak avatar Apr 29 '19 09:04 dkasak

" Author: Jordi Altayo <[email protected]>
" Description: support for textidote grammar and syntax checker

let g:ale_tex_textidote_executable = 'textidote'
let g:ale_tex_textidote_options = '--output singleline'

function! ale_linters#tex#textidote#Handle(buffer, lines) abort
    let l:pattern = '.*' . expand('%:t:r') . '\.tex(L\(\d\+\)C\(\d\+\)-L\d\+C\d\+): \(.*\)".*"'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        call add(l:output, {
        \   'lnum': l:match[1] + 0,
        \   'col' : l:match[2] + 0,
        \   'text': l:match[3],
        \   'type': 'E',
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('tex', {
\   'name': 'textidote',
\   'output_stream': 'stdout',
\   'executable': 'textidote',
\   'command': 'textidote --no-color --output singleline ' . expand('%'),
\   'callback': 'ale_linters#tex#textidote#Handle',
\})

Right now I don't have time to write the tests and create the pull request (will do it at some point) but this works with textidote, just place it under .vim/plugged/ale/ale_linters/tex/textidote.vim

jagjordi avatar Mar 13 '20 14:03 jagjordi

Please see quote from :help ale#linter#Define below. It should be safe to skip setting output_stream.

This argument defaults to 'stdout'.

rymdbar avatar Sep 10 '24 19:09 rymdbar