mirror of https://github.com/dense-analysis/ale
Support textlint for plaintext without textlintrc
This commit is contained in:
parent
dbf530e87f
commit
1d33d2cacf
|
@ -1,23 +1,9 @@
|
||||||
" Author: tokida https://rouger.info
|
" Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
|
||||||
" Description: textlint, a proofreading tool (https://textlint.github.io/)
|
" 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', {
|
call ale#linter#Define('markdown', {
|
||||||
\ 'name': 'textlint',
|
\ 'name': 'textlint',
|
||||||
\ 'executable': 'textlint',
|
\ 'executable_callback': 'ale#handlers#textlint#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#markdown#textlint#GetCommand',
|
\ 'command_callback': 'ale#handlers#textlint#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
|
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
|
||||||
\})
|
\})
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
" Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
|
||||||
|
" Description: textlint, a proofreading tool (https://textlint.github.io/)
|
||||||
|
|
||||||
|
call ale#linter#Define('text', {
|
||||||
|
\ 'name': 'textlint',
|
||||||
|
\ 'executable_callback': 'ale#handlers#textlint#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale#handlers#textlint#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
|
||||||
|
\})
|
|
@ -1,5 +1,34 @@
|
||||||
" Author: tokida https://rouger.info
|
" Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
|
||||||
" Description: Redpen, a proofreading tool (http://redpen.cc)
|
" 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
|
function! ale#handlers#textlint#HandleTextlintOutput(buffer, lines) abort
|
||||||
let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []})
|
let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []})
|
||||||
|
|
Loading…
Reference in New Issue