From b9428b7db09d9153f85e4d57efd9559d3a024ce8 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 24 Oct 2016 20:40:24 +0100 Subject: [PATCH] Merge #139 - Add Markdown linting support --- README.md | 1 + ale_linters/markdown/mdl.vim | 35 +++++++++++++++++++++++++++++++++++ doc/ale.txt | 1 + 3 files changed, 37 insertions(+) create mode 100644 ale_linters/markdown/mdl.vim diff --git a/README.md b/README.md index 4cbebcd..a7b6598 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ name. That seems to be the fairest way to arrange this table. | JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/) | | JSON | [jsonlint](http://zaa.ch/jsonlint/) | | Lua | [luacheck](https://github.com/mpeterv/luacheck) | +| Markdown | [mdl](https://github.com/mivok/markdownlint) | | MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) | | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | | PHP | [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | diff --git a/ale_linters/markdown/mdl.vim b/ale_linters/markdown/mdl.vim new file mode 100644 index 0000000..c984252 --- /dev/null +++ b/ale_linters/markdown/mdl.vim @@ -0,0 +1,35 @@ +" Author: Steve Dignam +" Description: Support for mdl, a markdown linter + +function! ale_linters#markdown#mdl#Handle(buffer, lines) abort + " matches: '(stdin):173: MD004 Unordered list style' + let l:pattern = ':\(\d*\): \(.*\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': 'W', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'mdl', +\ 'executable': 'mdl', +\ 'command': 'mdl', +\ 'callback': 'ale_linters#markdown#mdl#Handle' +\}) diff --git a/doc/ale.txt b/doc/ale.txt index c1abaa7..1706761 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -67,6 +67,7 @@ The following languages and tools are supported. * JavaScript: 'eslint', 'jscs', 'jshint' * JSON: 'jsonlint' * Lua: 'luacheck' +* Markdown: 'mdl' * MATLAB: 'mlint' * Perl: 'perl' (-c flag), 'perlcritic' * PHP: 'php' (-l flag), 'phpcs'