]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/markdown/mdl.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / ale_linters / markdown / mdl.vim
1 " Author: Steve Dignam <steve@dignam.xyz>, Josh Leeb-du Toit <joshleeb.com>
2 " Description: Support for mdl, a markdown linter.
3
4 call ale#Set('markdown_mdl_executable', 'mdl')
5 call ale#Set('markdown_mdl_options', '')
6
7 function! ale_linters#markdown#mdl#GetExecutable(buffer) abort
8     return ale#Var(a:buffer, 'markdown_mdl_executable')
9 endfunction
10
11 function! ale_linters#markdown#mdl#GetCommand(buffer) abort
12     let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer)
13     let l:exec_args = l:executable =~? 'bundle$'
14     \   ? ' exec mdl'
15     \   : ''
16
17     let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
18
19     return ale#Escape(l:executable) . l:exec_args
20     \   . ' -j' . (!empty(l:options) ? ' ' . l:options : '')
21 endfunction
22
23 function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
24     let l:output = []
25
26     for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
27         call add(l:output, {
28         \   'lnum': l:error['line'],
29         \   'code': l:error['rule']  . '/' . join(l:error['aliases'], '/'),
30         \   'text': l:error['description'],
31         \   'type': 'W',
32         \})
33     endfor
34
35     return l:output
36 endfunction
37
38 call ale#linter#Define('markdown', {
39 \   'name': 'mdl',
40 \   'executable': function('ale_linters#markdown#mdl#GetExecutable'),
41 \   'command': function('ale_linters#markdown#mdl#GetCommand'),
42 \   'callback': 'ale_linters#markdown#mdl#Handle'
43 \})