mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-26 04:46:53 +08:00
fix-proselint (#5074)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for AsciiDoc files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('asciidoc', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Jansen Mitchell https://github.com/JansenMitchell
|
||||
" Description: proselint for Fountain files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('fountain', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for Vim help files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('help', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for HTML files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for mail files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('mail', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: poohzrn https://github.com/poohzrn
|
||||
" Description: proselint for Markdown files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for nroff files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('nroff', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Cian Butler https://github.com/butlerx
|
||||
" Description: proselint for PO files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('po', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for Pod files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('pod', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" 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', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: poohzrn https://github.com/poohzrn
|
||||
" Description: proselint for TeX files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('tex', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for Texinfo files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('texinfo', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: poohzrn https://github.com/poohzrn
|
||||
" Description: proselint for text files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('text', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for XHTML files
|
||||
|
||||
call ale#Set('proselint_executable', 'proselint')
|
||||
|
||||
call ale#linter#Define('xhtml', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'executable': function('ale#proselint#GetExecutable'),
|
||||
\ 'command': function('ale#proselint#GetCommandWithVersionCheck'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
25
autoload/ale/proselint.vim
Normal file
25
autoload/ale/proselint.vim
Normal file
@@ -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
|
||||
28
test/test_proselint_get_command.vader
Normal file
28
test/test_proselint_get_command.vader
Normal file
@@ -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])
|
||||
17
test/test_proselint_get_executable.vader
Normal file
17
test/test_proselint_get_executable.vader
Normal file
@@ -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