From d59cb7b3c2fe23b06423d49f1b8cc6ec226e38c3 Mon Sep 17 00:00:00 2001 From: PsickOSSH <145741792+PsickOSSH@users.noreply.github.com> Date: Sun, 25 Jan 2026 08:29:03 +0100 Subject: [PATCH] fix-proselint (#5074) --- ale_linters/asciidoc/proselint.vim | 6 +++-- ale_linters/fountain/proselint.vim | 10 +++++---- ale_linters/help/proselint.vim | 6 +++-- ale_linters/html/proselint.vim | 6 +++-- ale_linters/mail/proselint.vim | 6 +++-- ale_linters/markdown/proselint.vim | 6 +++-- ale_linters/nroff/proselint.vim | 6 +++-- ale_linters/po/proselint.vim | 6 +++-- ale_linters/pod/proselint.vim | 6 +++-- ale_linters/rst/proselint.vim | 8 ++++--- ale_linters/tex/proselint.vim | 6 +++-- ale_linters/texinfo/proselint.vim | 6 +++-- ale_linters/text/proselint.vim | 6 +++-- ale_linters/xhtml/proselint.vim | 6 +++-- autoload/ale/proselint.vim | 25 +++++++++++++++++++++ test/test_proselint_get_command.vader | 28 ++++++++++++++++++++++++ test/test_proselint_get_executable.vader | 17 ++++++++++++++ 17 files changed, 129 insertions(+), 31 deletions(-) create mode 100644 autoload/ale/proselint.vim create mode 100644 test/test_proselint_get_command.vader create mode 100644 test/test_proselint_get_executable.vader diff --git a/ale_linters/asciidoc/proselint.vim b/ale_linters/asciidoc/proselint.vim index b636c067..15f9b255 100644 --- a/ale_linters/asciidoc/proselint.vim +++ b/ale_linters/asciidoc/proselint.vim @@ -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', \}) diff --git a/ale_linters/fountain/proselint.vim b/ale_linters/fountain/proselint.vim index 353a2e5f..2358c738 100644 --- a/ale_linters/fountain/proselint.vim +++ b/ale_linters/fountain/proselint.vim @@ -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', \}) diff --git a/ale_linters/help/proselint.vim b/ale_linters/help/proselint.vim index 62124502..3d13c297 100644 --- a/ale_linters/help/proselint.vim +++ b/ale_linters/help/proselint.vim @@ -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', \}) diff --git a/ale_linters/html/proselint.vim b/ale_linters/html/proselint.vim index 9fd7d671..5e7e94ef 100644 --- a/ale_linters/html/proselint.vim +++ b/ale_linters/html/proselint.vim @@ -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', \}) diff --git a/ale_linters/mail/proselint.vim b/ale_linters/mail/proselint.vim index 82c8d1f8..bb469ba7 100644 --- a/ale_linters/mail/proselint.vim +++ b/ale_linters/mail/proselint.vim @@ -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', \}) diff --git a/ale_linters/markdown/proselint.vim b/ale_linters/markdown/proselint.vim index 289d8819..3dbc94b2 100644 --- a/ale_linters/markdown/proselint.vim +++ b/ale_linters/markdown/proselint.vim @@ -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', \}) diff --git a/ale_linters/nroff/proselint.vim b/ale_linters/nroff/proselint.vim index a23e56b1..e2ae6142 100644 --- a/ale_linters/nroff/proselint.vim +++ b/ale_linters/nroff/proselint.vim @@ -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', \}) diff --git a/ale_linters/po/proselint.vim b/ale_linters/po/proselint.vim index ce132508..07a93f37 100644 --- a/ale_linters/po/proselint.vim +++ b/ale_linters/po/proselint.vim @@ -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', \}) diff --git a/ale_linters/pod/proselint.vim b/ale_linters/pod/proselint.vim index 2eb83f56..78c74b9e 100644 --- a/ale_linters/pod/proselint.vim +++ b/ale_linters/pod/proselint.vim @@ -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', \}) diff --git a/ale_linters/rst/proselint.vim b/ale_linters/rst/proselint.vim index 018347ae..e5c4124d 100644 --- a/ale_linters/rst/proselint.vim +++ b/ale_linters/rst/proselint.vim @@ -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', \}) diff --git a/ale_linters/tex/proselint.vim b/ale_linters/tex/proselint.vim index 35e764e2..c3598d99 100644 --- a/ale_linters/tex/proselint.vim +++ b/ale_linters/tex/proselint.vim @@ -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', \}) diff --git a/ale_linters/texinfo/proselint.vim b/ale_linters/texinfo/proselint.vim index 003e3a0f..f048362b 100644 --- a/ale_linters/texinfo/proselint.vim +++ b/ale_linters/texinfo/proselint.vim @@ -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', \}) diff --git a/ale_linters/text/proselint.vim b/ale_linters/text/proselint.vim index 281b4ffa..3d686655 100644 --- a/ale_linters/text/proselint.vim +++ b/ale_linters/text/proselint.vim @@ -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', \}) diff --git a/ale_linters/xhtml/proselint.vim b/ale_linters/xhtml/proselint.vim index dfad921f..dc19fab8 100644 --- a/ale_linters/xhtml/proselint.vim +++ b/ale_linters/xhtml/proselint.vim @@ -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', \}) diff --git a/autoload/ale/proselint.vim b/autoload/ale/proselint.vim new file mode 100644 index 00000000..e2f64e00 --- /dev/null +++ b/autoload/ale/proselint.vim @@ -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 diff --git a/test/test_proselint_get_command.vader b/test/test_proselint_get_command.vader new file mode 100644 index 00000000..06a91dc8 --- /dev/null +++ b/test/test_proselint_get_command.vader @@ -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]) diff --git a/test/test_proselint_get_executable.vader b/test/test_proselint_get_executable.vader new file mode 100644 index 00000000..3c6e99ce --- /dev/null +++ b/test/test_proselint_get_executable.vader @@ -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(''))