All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: q12321q <q12321q@gmail.com>
2 " Description: This file adds support for checking XML code with xmllint.
5 let g:ale_xml_xmllint_executable = get(g:, 'ale_xml_xmllint_executable', 'xmllint')
6 let g:ale_xml_xmllint_options = get(g:, 'ale_xml_xmllint_options', '')
8 function! ale_linters#xml#xmllint#GetCommand(buffer) abort
10 \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options'))
14 function! ale_linters#xml#xmllint#Handle(buffer, lines) abort
15 " Matches patterns lines like the following:
16 " file/path:123: error level : error message
17 let l:pattern_message = '\v^([^:]+):(\d+):\s*(([^:]+)\s*:\s+.*)$'
19 " parse column token line like that:
20 " file/path:123: parser error : Opening and ending tag mismatch: foo line 1 and bar
23 let l:pattern_column_token = '\v^\s*\^$'
28 " Parse error/warning lines
29 let l:match_message = matchlist(l:line, l:pattern_message)
31 if !empty(l:match_message)
32 let l:line = l:match_message[2] + 0
33 let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E'
34 let l:text = l:match_message[3]
45 " Parse column position
46 let l:match_column_token = matchlist(l:line, l:pattern_column_token)
48 if !empty(l:output) && !empty(l:match_column_token)
49 let l:previous = l:output[len(l:output) - 1]
50 let l:previous['col'] = len(l:match_column_token[0])
59 call ale#linter#Define('xml', {
61 \ 'output_stream': 'stderr',
62 \ 'executable': {b -> ale#Var(b, 'xml_xmllint_executable')},
63 \ 'command': function('ale_linters#xml#xmllint#GetCommand'),
64 \ 'callback': 'ale_linters#xml#xmllint#Handle',