]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/textlint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / handlers / textlint.vim
1 " Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
2 " Description: textlint, a proofreading tool (https://textlint.github.io/)
3
4 call ale#Set('textlint_executable', 'textlint')
5 call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('textlint_options', '')
7
8 function! ale#handlers#textlint#GetExecutable(buffer) abort
9     return ale#path#FindExecutable(a:buffer, 'textlint', [
10     \   'node_modules/.bin/textlint',
11     \   'node_modules/textlint/bin/textlint.js',
12     \])
13 endfunction
14
15 function! ale#handlers#textlint#GetCommand(buffer) abort
16     let l:executable = ale#handlers#textlint#GetExecutable(a:buffer)
17     let l:options = ale#Var(a:buffer, 'textlint_options')
18
19     return ale#node#Executable(a:buffer, l:executable)
20     \    . (!empty(l:options) ? ' ' . l:options : '')
21     \    . ' -f json --stdin --stdin-filename %s'
22 endfunction
23
24 function! ale#handlers#textlint#HandleTextlintOutput(buffer, lines) abort
25     let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []})
26     let l:output = []
27
28     for l:err in l:res.messages
29         call add(l:output, {
30         \   'text': l:err.message,
31         \   'type': 'W',
32         \   'code': l:err.ruleId,
33         \   'lnum': l:err.line,
34         \   'col' : l:err.column
35         \})
36     endfor
37
38     return l:output
39 endfunction