Skip to content

Commit 94a8a88

Browse files
authored
chktex: always use the right format and grab the error code (#5146)
Using -v0 works out of the box, but chktex grabs the "v0 format" from its configuration file: OutFormat { # -v0; silent mode %f%b%l%b%c%b%n%b%m!n # -v1; normal mode ... } Should the user modify the definition of v0, then the linter would no longer work. We therefore use "--format" to force the output format. Also grab the error code so it is correctly displayed. Closes: #3856
1 parent 5d4b088 commit 94a8a88

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

ale_linters/tex/chktex.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ function! ale_linters#tex#chktex#GetCommand(buffer, version) abort
1212
let l:options = ''
1313

1414
" Avoid bug when used without -p (last warning has gibberish for a filename)
15-
let l:options .= ' -v0 -p stdin -q'
15+
" Do not use -v0 as the meaning of v0 might be modified by the user in
16+
" their chktexrc file; instead, use --format to specify the output format.
17+
let l:options .= " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
1618

1719
" Avoid bug of reporting wrong column when using tabs (issue #723)
1820
if ale#semver#GTE(a:version, [1, 7, 7])
@@ -43,7 +45,8 @@ function! ale_linters#tex#chktex#Handle(buffer, lines) abort
4345
call add(l:output, {
4446
\ 'lnum': l:match[1] + 0,
4547
\ 'col': l:match[2] + 0,
46-
\ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')',
48+
\ 'text': l:match[4],
49+
\ 'code': l:match[3] + 0,
4750
\ 'type': 'W',
4851
\})
4952
endfor

test/linter/test_tex_chktex.vader

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Execute(The default command should be correct):
1010
AssertLinter 'chktex', [
1111
\ ale#Escape('chktex') . ' --version',
1212
\ ale#Escape('chktex')
13-
\ . ' -v0 -p stdin -q'
13+
\ . " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
1414
\ . ' -I',
1515
\]
1616

1717
" The version check should be cached.
1818
GivenCommandOutput []
1919
AssertLinter 'chktex', [
2020
\ ale#Escape('chktex')
21-
\ . ' -v0 -p stdin -q'
21+
\ . " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
2222
\ . ' -I',
2323
\]
2424

@@ -28,7 +28,7 @@ Execute(The default command should be correct):
2828
AssertLinter 'chktex', [
2929
\ ale#Escape('chktex') . ' --version',
3030
\ ale#Escape('chktex')
31-
\ . ' -v0 -p stdin -q'
31+
\ . " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
3232
\ . ' -S TabSize=1'
3333
\ . ' -I',
3434
\]
@@ -38,13 +38,13 @@ Execute(The executable should be configurable):
3838

3939
AssertLinter 'bin/foo',
4040
\ ale#Escape('bin/foo')
41-
\ . ' -v0 -p stdin -q'
41+
\ . " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
4242
\ . ' -I'
4343

4444
Execute(The options should be configurable):
4545
let b:ale_tex_chktex_options = '--something'
4646

4747
AssertLinter 'chktex',
4848
\ ale#Escape('chktex')
49-
\ . ' -v0 -p stdin -q'
49+
\ . " --format $'%f%b%l%b%c%b%n%b%m\n' -p stdin -q"
5050
\ . ' --something'

0 commit comments

Comments
 (0)