commit
3ddb858881
@ -114,7 +114,7 @@ formatting.
|
|||||||
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
|
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
|
||||||
| Mail | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
| Mail | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
||||||
| Make | [checkmake](https://github.com/mrtazz/checkmake) |
|
| Make | [checkmake](https://github.com/mrtazz/checkmake) |
|
||||||
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !!, [write-good](https://github.com/btford/write-good) |
|
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !!, [write-good](https://github.com/btford/write-good), [redpen](http://redpen.cc/) |
|
||||||
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
|
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
|
||||||
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
|
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
|
||||||
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
|
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
|
||||||
|
35
ale_linters/markdown/redpen.vim
Normal file
35
ale_linters/markdown/redpen.vim
Normal file
@ -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',
|
||||||
|
\})
|
@ -304,7 +304,7 @@ Notes:
|
|||||||
* Lua: `luacheck`
|
* Lua: `luacheck`
|
||||||
* Mail: `proselint`, `vale`
|
* Mail: `proselint`, `vale`
|
||||||
* Make: `checkmake`
|
* Make: `checkmake`
|
||||||
* Markdown: `mdl`, `proselint`, `vale`, `remark-lint`, `write-good`
|
* Markdown: `mdl`, `proselint`, `vale`, `remark-lint`, `write-good`, `redpen`
|
||||||
* MATLAB: `mlint`
|
* MATLAB: `mlint`
|
||||||
* Nim: `nim check`!!
|
* Nim: `nim check`!!
|
||||||
* nix: `nix-instantiate`
|
* nix: `nix-instantiate`
|
||||||
|
67
test/handler/test_redpen_handler.vader
Normal file
67
test/handler/test_redpen_handler.vader
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
Before:
|
||||||
|
runtime! ale_linters/markdown/redpen.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(redpen handler should handle errors output):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 9,
|
||||||
|
\ 'end_lnum': 1,
|
||||||
|
\ 'end_col': 15,
|
||||||
|
\ 'text': 'Found possibly misspelled word "plugin". (Spelling)',
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 1,
|
||||||
|
\ 'text': 'Found possibly misspelled word "NeoVim". (Spelling)',
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#markdown#redpen#HandleErrors(bufnr(''), [
|
||||||
|
\ '[',
|
||||||
|
\ ' {',
|
||||||
|
\ ' "document": "test.md",',
|
||||||
|
\ ' "errors": [',
|
||||||
|
\ ' {',
|
||||||
|
\ ' "sentence": "ALE is a plugin for providing linting in NeoVim and Vim 8 while you edit your text files.",',
|
||||||
|
\ ' "endPosition": {',
|
||||||
|
\ ' "offset": 15,',
|
||||||
|
\ ' "lineNum": 1',
|
||||||
|
\ ' },',
|
||||||
|
\ ' "validator": "Spelling",',
|
||||||
|
\ ' "lineNum": 1,',
|
||||||
|
\ ' "sentenceStartColumnNum": 0,',
|
||||||
|
\ ' "message": "Found possibly misspelled word \"plugin\".",',
|
||||||
|
\ ' "startPosition": {',
|
||||||
|
\ ' "offset": 9,',
|
||||||
|
\ ' "lineNum": 1',
|
||||||
|
\ ' }',
|
||||||
|
\ ' },',
|
||||||
|
\ ' {',
|
||||||
|
\ ' "sentence": "ALE is a plugin for providing linting in NeoVim and Vim 8 while you edit your text files.",',
|
||||||
|
\ ' "validator": "Spelling",',
|
||||||
|
\ ' "lineNum": 1,',
|
||||||
|
\ ' "sentenceStartColumnNum": 0,',
|
||||||
|
\ ' "message": "Found possibly misspelled word \"NeoVim\"."',
|
||||||
|
\ ' }',
|
||||||
|
\ ' ]',
|
||||||
|
\ ' }',
|
||||||
|
\ ']',
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(redpen handler should no error output):
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#markdown#redpen#HandleErrors(bufnr(''), [
|
||||||
|
\ '[',
|
||||||
|
\ ' {',
|
||||||
|
\ ' "document": "test.md",',
|
||||||
|
\ ' "errors": []',
|
||||||
|
\ ' }',
|
||||||
|
\ ']',
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user