summaryrefslogtreecommitdiff
path: root/ale_linters/markdown
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2017-11-16 18:12:08 +0900
committerrhysd <lin90162@yahoo.co.jp>2017-11-16 18:12:08 +0900
commit981cb95d80714fd70b55d99f164c2d3158315206 (patch)
tree9d75445d0abaff2197cd22ec044c2fc20f6f046b /ale_linters/markdown
parent1d65e5692f7075bad6806d88eb11961ea32d3e7d (diff)
downloadale-981cb95d80714fd70b55d99f164c2d3158315206.zip
add redpen support
Diffstat (limited to 'ale_linters/markdown')
-rw-r--r--ale_linters/markdown/redpen.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/ale_linters/markdown/redpen.vim b/ale_linters/markdown/redpen.vim
new file mode 100644
index 00000000..00a19a93
--- /dev/null
+++ b/ale_linters/markdown/redpen.vim
@@ -0,0 +1,32 @@
+" Author: rhysd https://rhysd.github.io
+" Description: Redpen, a proofreading tool (http://redpen.cc)
+
+function! ale_linters#markdown#redpen#HandleErrors(buffer, lines) abort
+ " Only one file was passed to redpen. So response array has only one
+ " element.
+ let l:res = json_decode(join(a:lines))[0]
+ let l:errors = []
+ for l:err in l:res.errors
+ if has_key(l:err, 'startPosition')
+ let l:lnum = l:err.startPosition.lineNum
+ let l:col = l:err.startPosition.offset
+ else
+ let l:lnum = l:err.lineNum
+ let l:col = l:err.sentenceStartColumnNum + 1
+ endif
+ call add(l:errors, {
+ \ 'lnum': l:lnum,
+ \ 'col': l:col,
+ \ 'text': l:err.message . ' (' . l:err.validator . ')',
+ \ 'type': 'W',
+ \})
+ endfor
+ return l:errors
+endfunction
+
+call ale#linter#Define('markdown', {
+\ 'name': 'redpen',
+\ 'executable': 'redpen',
+\ 'command': 'redpen -r json %t',
+\ 'callback': 'ale_linters#markdown#redpen#HandleErrors',
+\})