summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2017-11-16 10:44:52 +0000
committerGitHub <noreply@github.com>2017-11-16 10:44:52 +0000
commit3ddb858881c7b18ec8dae03ab915e5bb453f0286 (patch)
treec2d2cd9c3ba58043b499407cdd80ab0e3e3b1b08 /ale_linters
parentf90a2d54744d7bfe985b0cd48a00012afecdc754 (diff)
parente232ea07c23d3e6f1b6e621e896f27545e5b10c7 (diff)
downloadale-3ddb858881c7b18ec8dae03ab915e5bb453f0286.zip
Merge pull request #1137 from rhysd/redpen
Add Redpen support
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/markdown/redpen.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/markdown/redpen.vim b/ale_linters/markdown/redpen.vim
new file mode 100644
index 00000000..38fe2308
--- /dev/null
+++ b/ale_linters/markdown/redpen.vim
@@ -0,0 +1,35 @@
+" 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:output = []
+ for l:err in l:res.errors
+ let l:item = {
+ \ 'text': l:err.message . ' (' . l:err.validator . ')',
+ \ 'type': 'W',
+ \}
+ if has_key(l:err, 'startPosition')
+ let l:item.lnum = l:err.startPosition.lineNum
+ let l:item.col = l:err.startPosition.offset
+ if has_key(l:err, 'endPosition')
+ let l:item.end_lnum = l:err.endPosition.lineNum
+ let l:item.end_col = l:err.endPosition.offset
+ endif
+ else
+ let l:item.lnum = l:err.lineNum
+ let l:item.col = l:err.sentenceStartColumnNum + 1
+ endif
+ call add(l:output, l:item)
+ endfor
+ return l:output
+endfunction
+
+call ale#linter#Define('markdown', {
+\ 'name': 'redpen',
+\ 'executable': 'redpen',
+\ 'command': 'redpen -r json %t',
+\ 'callback': 'ale_linters#markdown#redpen#HandleErrors',
+\})