2018-02-26 03:46:51 +00:00
|
|
|
" Author: Steve Dignam <steve@dignam.xyz>, Josh Leeb-du Toit <joshleeb.com>
|
|
|
|
" Description: Support for mdl, a markdown linter.
|
|
|
|
|
|
|
|
call ale#Set('markdown_mdl_executable', 'mdl')
|
|
|
|
call ale#Set('markdown_mdl_options', '')
|
2016-10-24 19:40:24 +00:00
|
|
|
|
|
|
|
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
|
|
|
" matches: '(stdin):173: MD004 Unordered list style'
|
|
|
|
let l:pattern = ':\(\d*\): \(.*\)$'
|
|
|
|
let l:output = []
|
|
|
|
|
2017-04-17 23:35:53 +00:00
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
2016-10-24 19:40:24 +00:00
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': l:match[1] + 0,
|
|
|
|
\ 'text': l:match[2],
|
|
|
|
\ 'type': 'W',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
2018-02-26 03:46:51 +00:00
|
|
|
function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
|
|
|
let l:executable = ale#Var(a:buffer, 'markdown_mdl_executable')
|
|
|
|
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
|
|
|
|
|
|
|
return l:executable . (!empty(l:options) ? ' ' . l:options : '')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2016-10-24 19:40:24 +00:00
|
|
|
call ale#linter#Define('markdown', {
|
|
|
|
\ 'name': 'mdl',
|
|
|
|
\ 'executable': 'mdl',
|
2018-02-26 03:46:51 +00:00
|
|
|
\ 'command_callback': 'ale_linters#markdown#mdl#GetCommand',
|
2016-10-24 19:40:24 +00:00
|
|
|
\ 'callback': 'ale_linters#markdown#mdl#Handle'
|
|
|
|
\})
|