2018-03-31 10:55:20 -04: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', '')
|
|
|
|
|
|
|
|
function! ale_linters#markdown#mdl#GetExecutable(buffer) abort
|
|
|
|
return ale#Var(a:buffer, 'markdown_mdl_executable')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
|
|
|
let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer)
|
2018-06-14 06:31:12 -04:00
|
|
|
let l:exec_args = l:executable =~? 'bundle$'
|
|
|
|
\ ? ' exec mdl'
|
|
|
|
\ : ''
|
|
|
|
|
2018-03-31 10:55:20 -04:00
|
|
|
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
|
|
|
|
2018-06-14 06:31:12 -04:00
|
|
|
return ale#Escape(l:executable) . l:exec_args
|
2019-11-16 10:28:42 -05:00
|
|
|
\ . ' -j' . (!empty(l:options) ? ' ' . l:options : '')
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
|
|
|
let l:output = []
|
|
|
|
|
2019-11-16 10:28:42 -05:00
|
|
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
2018-03-31 10:55:20 -04:00
|
|
|
call add(l:output, {
|
2019-11-16 10:28:42 -05:00
|
|
|
\ 'lnum': l:error['line'],
|
|
|
|
\ 'code': l:error['rule'] . '/' . join(l:error['aliases'], '/'),
|
|
|
|
\ 'text': l:error['description'],
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'type': 'W',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('markdown', {
|
|
|
|
\ 'name': 'mdl',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': function('ale_linters#markdown#mdl#GetExecutable'),
|
|
|
|
\ 'command': function('ale_linters#markdown#mdl#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#markdown#mdl#Handle'
|
|
|
|
\})
|