Support textlint for reStructuredText (#1978)
* Support textlint for reStructuredText * Add linter test for textlint rst
This commit is contained in:
parent
56b7dca623
commit
7f176390fc
5 changed files with 91 additions and 2 deletions
|
@ -179,7 +179,7 @@ formatting.
|
||||||
| QML | [qmlfmt](https://github.com/jesperhh/qmlfmt), [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) |
|
| QML | [qmlfmt](https://github.com/jesperhh/qmlfmt), [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) |
|
||||||
| R | [lintr](https://github.com/jimhester/lintr) |
|
| R | [lintr](https://github.com/jimhester/lintr) |
|
||||||
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [refmt](https://github.com/reasonml/reason-cli) |
|
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [refmt](https://github.com/reasonml/reason-cli) |
|
||||||
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [textlint](https://textlint.github.io/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||||
| Re:VIEW | [redpen](http://redpen.cc/) |
|
| Re:VIEW | [redpen](http://redpen.cc/) |
|
||||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo), [solargraph](https://solargraph.org), [standardrb](https://github.com/testdouble/standard) |
|
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo), [solargraph](https://solargraph.org), [standardrb](https://github.com/testdouble/standard) |
|
||||||
|
|
9
ale_linters/rst/textlint.vim
Normal file
9
ale_linters/rst/textlint.vim
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
" Author: hokorobi <hokorobi.hokorobi@gmail.com>
|
||||||
|
" Description: textlint, a proofreading tool (https://textlint.github.io/)
|
||||||
|
|
||||||
|
call ale#linter#Define('rst', {
|
||||||
|
\ 'name': 'textlint',
|
||||||
|
\ 'executable_callback': 'ale#handlers#textlint#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale#handlers#textlint#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
|
||||||
|
\})
|
|
@ -2,6 +2,20 @@
|
||||||
ALE reStructuredText Integration *ale-restructuredtext-options*
|
ALE reStructuredText Integration *ale-restructuredtext-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
textlint *ale-restructuredtext-textlint*
|
||||||
|
|
||||||
|
To use textlint at reStructuredText, please install `textlint-plugin-rst`.
|
||||||
|
https://github.com/jimo1001/textlint-plugin-rst
|
||||||
|
>
|
||||||
|
$ npm install textlint-plugin-rst
|
||||||
|
|
||||||
|
To install `textlint-plugin-rst`, `docutils-ast-writer` python package
|
||||||
|
must be installed.
|
||||||
|
See: https://github.com/jimo1001/docutils-ast-writer
|
||||||
|
|
||||||
|
See |ale-text-textlint|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
write-good *ale-restructuredtext-write-good*
|
write-good *ale-restructuredtext-write-good*
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,7 @@ CONTENTS *ale-contents*
|
||||||
ols.................................|ale-reasonml-ols|
|
ols.................................|ale-reasonml-ols|
|
||||||
refmt...............................|ale-reasonml-refmt|
|
refmt...............................|ale-reasonml-refmt|
|
||||||
restructuredtext......................|ale-restructuredtext-options|
|
restructuredtext......................|ale-restructuredtext-options|
|
||||||
|
textlint............................|ale-restructuredtext-textlint|
|
||||||
write-good..........................|ale-restructuredtext-write-good|
|
write-good..........................|ale-restructuredtext-write-good|
|
||||||
ruby..................................|ale-ruby-options|
|
ruby..................................|ale-ruby-options|
|
||||||
brakeman............................|ale-ruby-brakeman|
|
brakeman............................|ale-ruby-brakeman|
|
||||||
|
@ -486,7 +487,7 @@ Notes:
|
||||||
* QML: `qmlfmt`, `qmllint`
|
* QML: `qmlfmt`, `qmllint`
|
||||||
* R: `lintr`
|
* R: `lintr`
|
||||||
* ReasonML: `merlin`, `ols`, `refmt`
|
* ReasonML: `merlin`, `ols`, `refmt`
|
||||||
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good`
|
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `textlint`, `vale`, `write-good`
|
||||||
* Re:VIEW: `redpen`
|
* Re:VIEW: `redpen`
|
||||||
* RPM spec: `rpmlint`
|
* RPM spec: `rpmlint`
|
||||||
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`, `solargraph`, `standardrb`
|
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`, `solargraph`, `standardrb`
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
" Author: januswel, w0rp
|
||||||
|
|
||||||
|
Before:
|
||||||
|
" This is just one language for the linter.
|
||||||
|
call ale#assert#SetUpLinterTest('rst', 'textlint')
|
||||||
|
|
||||||
|
" The configuration is shared between many languages.
|
||||||
|
Save g:ale_textlint_executable
|
||||||
|
Save g:ale_textlint_use_global
|
||||||
|
Save g:ale_textlint_options
|
||||||
|
|
||||||
|
let g:ale_textlint_executable = 'textlint'
|
||||||
|
let g:ale_textlint_use_global = 0
|
||||||
|
let g:ale_textlint_options = ''
|
||||||
|
|
||||||
|
unlet! b:ale_textlint_executable
|
||||||
|
unlet! b:ale_textlint_use_global
|
||||||
|
unlet! b:ale_textlint_options
|
||||||
|
|
||||||
|
After:
|
||||||
|
unlet! b:command_tail
|
||||||
|
unlet! b:ale_textlint_executable
|
||||||
|
unlet! b:ale_textlint_use_global
|
||||||
|
unlet! b:ale_textlint_options
|
||||||
|
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The default command should be correct):
|
||||||
|
AssertLinter 'textlint',
|
||||||
|
\ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s'
|
||||||
|
|
||||||
|
Execute(The executable should be configurable):
|
||||||
|
let b:ale_textlint_executable = 'foobar'
|
||||||
|
|
||||||
|
AssertLinter 'foobar',
|
||||||
|
\ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s'
|
||||||
|
|
||||||
|
Execute(The options should be configurable):
|
||||||
|
let b:ale_textlint_options = '--something'
|
||||||
|
|
||||||
|
AssertLinter 'textlint',
|
||||||
|
\ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s'
|
||||||
|
|
||||||
|
Execute(The local executable from .bin should be used if available):
|
||||||
|
call ale#test#SetFilename('textlint_paths/with_bin_path/foo.txt')
|
||||||
|
|
||||||
|
AssertLinter
|
||||||
|
\ ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'),
|
||||||
|
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'))
|
||||||
|
\ . ' -f json --stdin --stdin-filename %s'
|
||||||
|
|
||||||
|
Execute(The local executable from textlint/bin should be used if available):
|
||||||
|
call ale#test#SetFilename('textlint_paths/with_textlint_bin_path/foo.txt')
|
||||||
|
|
||||||
|
if has('win32')
|
||||||
|
AssertLinter
|
||||||
|
\ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
|
||||||
|
\ ale#Escape('node.exe') . ' ' . ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
|
||||||
|
\ . ' -f json --stdin --stdin-filename %s'
|
||||||
|
else
|
||||||
|
AssertLinter
|
||||||
|
\ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
|
||||||
|
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
|
||||||
|
\ . ' -f json --stdin --stdin-filename %s'
|
||||||
|
endif
|
Reference in a new issue