New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add textlint support #1383

Merged
merged 9 commits into from Mar 18, 2018
View
@@ -121,7 +121,7 @@ formatting.
| Lua | [luac](https://www.lua.org/manual/5.1/luac.html), [luacheck](https://github.com/mpeterv/luacheck) |
| Mail | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
| Make | [checkmake](https://github.com/mrtazz/checkmake) |
| Markdown | [alex](https://github.com/wooorm/alex) !!, [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
| Markdown | [alex](https://github.com/wooorm/alex) !!, [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) , [textlint](https://textlint.github.io/)|
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
@@ -0,0 +1,23 @@
" Author: tokida https://rouger.info
" Description: textlint, a proofreading tool (https://textlint.github.io/)
function! ale_linters#markdown#textlint#GetCommand(buffer) abort
let l:cmd_path = ale#path#FindNearestFile(a:buffer, '.textlintrc')
if !empty(l:cmd_path)
return 'textlint'
\ . ' -c '
\ . l:cmd_path
\ . ' -f json %t'
endif
return ''
endfunction
call ale#linter#Define('markdown', {
\ 'name': 'textlint',
\ 'executable': 'textlint',
\ 'command_callback': 'ale_linters#markdown#textlint#GetCommand',
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
\})
@@ -0,0 +1,19 @@
" Author: tokida https://rouger.info
" Description: Redpen, a proofreading tool (http://redpen.cc)
function! ale#handlers#textlint#HandleTextlintOutput(buffer, lines) abort
let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []})
let l:output = []
for l:err in l:res.messages
call add(l:output, {
\ 'text': l:err.message,
\ 'type': 'W',
\ 'code': l:err.ruleId,
\ 'lnum': l:err.line,
\ 'col' : l:err.column
\})
endfor
return l:output
endfunction
View
@@ -342,7 +342,7 @@ Notes:
* Lua: `luac`, `luacheck`
* Mail: `alex`!!, `proselint`, `vale`
* Make: `checkmake`
* Markdown: `alex`!!, `mdl`, `prettier`, `proselint`, `redpen`, `remark-lint`, `vale`, `write-good`
* Markdown: `alex`!!, `mdl`, `prettier`, `proselint`, `redpen`, `remark-lint`, `vale`, `write-good`, `textlint`
* MATLAB: `mlint`
* Nim: `nim check`!!
* nix: `nix-instantiate`
@@ -0,0 +1,41 @@
Before:
runtime! ale_linters/markdown/textlint.vim
After:
call ale#linter#Reset()
Execute(textlint handler should handle errors output):
AssertEqual
\ [
\ {
\ 'lnum': 16,
\ 'col': 50,
\ 'text': 'Found possibly misspelled word "NeoVim".',
\ 'type': 'W',
\ 'code': 'preset-japanese/no-doubled-joshi',
\ },
\ ],
\ ale#handlers#textlint#HandleTextlintOutput(bufnr(''), [
\ '[',
\ ' {',
\ ' "filePath": "test.md",',
\ ' "messages": [',
\ ' {',
\ ' "type": "lint",',
\ ' "ruleId": "preset-japanese/no-doubled-joshi",',
\ ' "index": 1332,',
\ ' "line": 16,',
\ ' "column": 50,',
\ ' "severity": 2,',
\ ' "message": "Found possibly misspelled word \"NeoVim\"."',
\ ' }',
\ ' ]',
\ ' }',
\ ']',
\ ])
Execute(textlint handler should no error output):
AssertEqual
\ [],
\ ale#handlers#textlint#HandleTextlintOutput(bufnr(''), [
\ ])
ProTip! Use n and p to navigate between commits in a pull request.