fix-proselint (#5074)

This commit is contained in:
PsickOSSH
2026-01-25 08:29:03 +01:00
committed by GitHub
parent c0dd8167a6
commit d59cb7b3c2
17 changed files with 129 additions and 31 deletions

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View File

@@ -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',
\})

View 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

View 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])

View 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(''))