Add configurable options support for redpen linter (#5006)

Redpen linter previously had hardcoded command-line options and duplicated
linter definitions across all supported file types (asciidoc, markdown,
review, rst, tex, text). This refactoring centralizes the linter definition
and adds support for user-configurable options via g:ale_redpen_options.

Key changes:
- Created ale#handlers#redpen#DefineLinter() to eliminate code duplication
- Added ale#handlers#redpen#GetCommand() to support configurable options
- All file types now use shared configuration and command building
- Added comprehensive test coverage for option handling
- Updated documentation for all affected file types

This allows users to customize redpen behavior with additional command-line
options while maintaining backward compatibility and reducing maintenance
overhead.
This commit is contained in:
Jason Weir
2025-08-13 06:06:06 -06:00
committed by GitHub
parent ac691b0b89
commit 5dfd1fdb9a
13 changed files with 96 additions and 38 deletions

View File

@@ -1,6 +1,8 @@
" Author: rhysd https://rhysd.github.io
" Description: Redpen, a proofreading tool (http://redpen.cc)
call ale#Set('redpen_options', '')
function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
" Only one file was passed to redpen. So response array has only one
" element.
@@ -63,3 +65,14 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
return l:output
endfunction
" Define the redpen linter for a given filetype.
function! ale#handlers#redpen#DefineLinter(filetype) abort
call ale#linter#Define(a:filetype, {
\ 'name': 'redpen',
\ 'executable': 'redpen',
\ 'command': {b -> 'redpen -f ' . a:filetype . ' -r json' . ale#Pad(ale#Var(b, 'redpen_options')) . ' %t'},
\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput',
\})
endfunction