summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authoryasuhiroki <yasuhiroki.duck@gmail.com>2018-03-20 08:57:09 +0900
committeryasuhiroki <yasuhiroki.duck@gmail.com>2018-03-24 14:40:44 +0900
commit1d33d2cacff9816ce487f9000675851041c25901 (patch)
tree55f23e2d49361584a68cdac050d7f066fa328139 /autoload
parentdbf530e87fde81397712a85ed87b6a15131afd4c (diff)
downloadale-1d33d2cacff9816ce487f9000675851041c25901.zip
Support textlint for plaintext without textlintrc
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/textlint.vim33
1 files changed, 31 insertions, 2 deletions
diff --git a/autoload/ale/handlers/textlint.vim b/autoload/ale/handlers/textlint.vim
index 0aae57ef..80f68e10 100644
--- a/autoload/ale/handlers/textlint.vim
+++ b/autoload/ale/handlers/textlint.vim
@@ -1,5 +1,34 @@
-" Author: tokida https://rouger.info
-" Description: Redpen, a proofreading tool (http://redpen.cc)
+" Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
+" Description: textlint, a proofreading tool (https://textlint.github.io/)
+
+call ale#Set('textlint_executable', 'textlint')
+call ale#Set('textlint_use_global', 0)
+call ale#Set('textlint_options', '')
+
+function! ale#handlers#textlint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'textlint', [
+ \ 'node_modules/.bin/textlint',
+ \ 'node_modules/textlint/bin/textlint.js',
+ \])
+endfunction
+
+function! ale#handlers#textlint#GetCommand(buffer) abort
+ let l:cmd_path = ale#path#FindNearestFile(a:buffer, '.textlintrc')
+ let l:options = ale#Var(a:buffer, 'textlint_options')
+
+ if !empty(l:cmd_path)
+ return 'textlint'
+ \ . ' -c '
+ \ . l:cmd_path
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' -f json %t'
+ endif
+
+ return 'textlint'
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' -f json %t'
+endfunction
+
function! ale#handlers#textlint#HandleTextlintOutput(buffer, lines) abort
let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []})