mirror of
https://github.com/dense-analysis/ale.git
synced 2026-08-12 19:06:53 +08:00
fix-proselint (#5074)
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for AsciiDoc files
|
" Description: proselint for AsciiDoc files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('asciidoc', {
|
call ale#linter#Define('asciidoc', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Jansen Mitchell https://github.com/JansenMitchell
|
" Author: Jansen Mitchell https://github.com/JansenMitchell
|
||||||
" Description: proselint for Fountain files
|
" Description: proselint for Fountain files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('fountain', {
|
call ale#linter#Define('fountain', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for Vim help files
|
" Description: proselint for Vim help files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('help', {
|
call ale#linter#Define('help', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for HTML files
|
" Description: proselint for HTML files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('html', {
|
call ale#linter#Define('html', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for mail files
|
" Description: proselint for mail files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('mail', {
|
call ale#linter#Define('mail', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: poohzrn https://github.com/poohzrn
|
" Author: poohzrn https://github.com/poohzrn
|
||||||
" Description: proselint for Markdown files
|
" Description: proselint for Markdown files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('markdown', {
|
call ale#linter#Define('markdown', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for nroff files
|
" Description: proselint for nroff files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('nroff', {
|
call ale#linter#Define('nroff', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Cian Butler https://github.com/butlerx
|
" Author: Cian Butler https://github.com/butlerx
|
||||||
" Description: proselint for PO files
|
" Description: proselint for PO files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('po', {
|
call ale#linter#Define('po', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for Pod files
|
" Description: proselint for Pod files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('pod', {
|
call ale#linter#Define('pod', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for reStructuredText files
|
" Description: proselint for reStructuredrst files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('rst', {
|
call ale#linter#Define('rst', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: poohzrn https://github.com/poohzrn
|
" Author: poohzrn https://github.com/poohzrn
|
||||||
" Description: proselint for TeX files
|
" Description: proselint for TeX files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('tex', {
|
call ale#linter#Define('tex', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for Texinfo files
|
" Description: proselint for Texinfo files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('texinfo', {
|
call ale#linter#Define('texinfo', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: poohzrn https://github.com/poohzrn
|
" Author: poohzrn https://github.com/poohzrn
|
||||||
" Description: proselint for text files
|
" Description: proselint for text files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('text', {
|
call ale#linter#Define('text', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Daniel M. Capella https://github.com/polyzen
|
" Author: Daniel M. Capella https://github.com/polyzen
|
||||||
" Description: proselint for XHTML files
|
" Description: proselint for XHTML files
|
||||||
|
|
||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
call ale#linter#Define('xhtml', {
|
call ale#linter#Define('xhtml', {
|
||||||
\ 'name': 'proselint',
|
\ 'name': 'proselint',
|
||||||
\ 'executable': 'proselint',
|
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||||
\ 'command': 'proselint %t',
|
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
call ale#Set('proselint_executable', 'proselint')
|
||||||
|
|
||||||
|
function! ale#proselint#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'proselint_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#proselint#GetCommand(buffer, version) abort
|
||||||
|
let l:executable = ale#proselint#GetExecutable(a:buffer)
|
||||||
|
let l:escaped_exec = ale#Escape(l:executable)
|
||||||
|
|
||||||
|
if ale#semver#GTE(a:version, [0, 16, 0])
|
||||||
|
return l:escaped_exec . ' check %t'
|
||||||
|
else
|
||||||
|
return l:escaped_exec . ' %t'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#proselint#GetCommandWithVersionCheck(buffer) abort
|
||||||
|
return ale#semver#RunWithVersionCheck(
|
||||||
|
\ a:buffer,
|
||||||
|
\ ale#proselint#GetExecutable(a:buffer),
|
||||||
|
\ '%e version --output-format json',
|
||||||
|
\ function('ale#proselint#GetCommand')
|
||||||
|
\)
|
||||||
|
endfunction
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
Before:
|
||||||
|
runtime autoload/ale/proselint.vim
|
||||||
|
|
||||||
|
let b:ale_proselint_executable = 'proselint'
|
||||||
|
|
||||||
|
After:
|
||||||
|
unlet! b:ale_proselint_executable
|
||||||
|
|
||||||
|
Execute(Command for proselint >= 0.16.0 should use 'check'):
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('proselint') . ' check %t',
|
||||||
|
\ ale#proselint#GetCommand(bufnr(''), [0, 16, 0])
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('proselint') . ' check %t',
|
||||||
|
\ ale#proselint#GetCommand(bufnr(''), [0, 17, 0])
|
||||||
|
|
||||||
|
Execute(Command for proselint < 0.16.0 should use standard arguments):
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('proselint') . ' %t',
|
||||||
|
\ ale#proselint#GetCommand(bufnr(''), [0, 15, 0])
|
||||||
|
|
||||||
|
Execute(Command should respect custom executable path):
|
||||||
|
let b:ale_proselint_executable = '/custom/path/to/proselint'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('/custom/path/to/proselint') . ' check %t',
|
||||||
|
\ ale#proselint#GetCommand(bufnr(''), [0, 16, 0])
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_proselint_executable
|
||||||
|
runtime autoload/ale/proselint.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
Execute(Default executable should be detected correctly):
|
||||||
|
AssertEqual
|
||||||
|
\ 'proselint',
|
||||||
|
\ ale#proselint#GetExecutable(bufnr(''))
|
||||||
|
|
||||||
|
Execute(User specified executable should override default):
|
||||||
|
let g:ale_proselint_executable = '/path/to/proselint-bin'
|
||||||
|
AssertEqual
|
||||||
|
\ '/path/to/proselint-bin',
|
||||||
|
\ ale#proselint#GetExecutable(bufnr(''))
|
||||||
Reference in New Issue
Block a user