summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/vim/vint.vim28
-rw-r--r--test/handler/test_vint_handler.vader29
2 files changed, 53 insertions, 4 deletions
diff --git a/ale_linters/vim/vint.vim b/ale_linters/vim/vint.vim
index 18ae2e4c..adf2b4ab 100644
--- a/ale_linters/vim/vint.vim
+++ b/ale_linters/vim/vint.vim
@@ -36,6 +36,32 @@ function! ale_linters#vim#vint#GetCommand(buffer, version_output) abort
\ . ' %t'
endfunction
+let s:word_regex_list = [
+\ '\v^Undefined variable: ([^ ]+)',
+\ '\v^Make the scope explicit like ...([^ ]+). ',
+\ '\v^.*start with a capital or contain a colon: ([^ ]+)',
+\ '\v.*instead of .(\=[=~]).',
+\]
+
+function! ale_linters#vim#vint#Handle(buffer, lines) abort
+ let l:loclist = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines)
+
+ for l:item in l:loclist
+ let l:match = []
+
+ for l:regex in s:word_regex_list
+ let l:match = matchlist(l:item.text, l:regex)
+
+ if !empty(l:match)
+ let l:item.end_col = l:item.col + len(l:match[1]) - 1
+ break
+ endif
+ endfor
+ endfor
+
+ return l:loclist
+endfunction
+
call ale#linter#Define('vim', {
\ 'name': 'vint',
\ 'executable': 'vint',
@@ -43,5 +69,5 @@ call ale#linter#Define('vim', {
\ {'callback': 'ale_linters#vim#vint#VersionCommand', 'output_stream': 'stderr'},
\ {'callback': 'ale_linters#vim#vint#GetCommand', 'output_stream': 'stdout'},
\ ],
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale_linters#vim#vint#Handle',
\})
diff --git a/test/handler/test_vint_handler.vader b/test/handler/test_vint_handler.vader
index c5af85c4..8747979c 100644
--- a/test/handler/test_vint_handler.vader
+++ b/test/handler/test_vint_handler.vader
@@ -1,6 +1,10 @@
-Execute(The vint handler should parse error messages correctly):
- :file! gxc.vim
+Before:
+ runtime ale_linters/vim/vint.vim
+
+After:
+ call ale#linter#Reset()
+Execute(The vint handler should parse error messages correctly):
AssertEqual
\ [
\ {
@@ -12,25 +16,44 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 3,
\ 'col': 17,
+ \ 'end_col': 18,
\ 'text': 'Use robust operators ''==#'' or ''==?'' instead of ''=='' (see Google VimScript Style Guide (Matching))',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 3,
\ 'col': 8,
+ \ 'end_col': 15,
\ 'text': 'Make the scope explicit like ''l:filename'' (see Anti-pattern of vimrc (Scope of identifier))',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 7,
\ 'col': 8,
+ \ 'end_col': 15,
\ 'text': 'Undefined variable: filename (see :help E738)',
\ 'type': 'W',
\ },
+ \ {
+ \ 'lnum': 8,
+ \ 'col': 11,
+ \ 'end_col': 16,
+ \ 'text': 'E128: Function name must start with a capital or contain a colon: foobar (see ynkdir/vim-vimlparser)',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 9,
+ \ 'col': 12,
+ \ 'end_col': 13,
+ \ 'text': 'Use robust operators ''=~#'' or ''=~?'' instead of ''=~'' (see Google VimScript Style Guide (Matching))',
+ \ 'type': 'W',
+ \ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale_linters#vim#vint#Handle(bufnr(''), [
\ 'gcc.vim:1:1: warning: Use scriptencoding when multibyte char exists (see :help :script encoding)',
\ 'gcc.vim:3:17: warning: Use robust operators `==#` or `==?` instead of `==` (see Google VimScript Style Guide (Matching))',
\ 'gcc.vim:3:8: style_problem: Make the scope explicit like `l:filename` (see Anti-pattern of vimrc (Scope of identifier))',
\ 'gcc.vim:7:8: warning: Undefined variable: filename (see :help E738)',
+ \ 'gcc.vim:8:11: error: E128: Function name must start with a capital or contain a colon: foobar (see ynkdir/vim-vimlparser)',
+ \ 'gcc.vim:9:12: warning: Use robust operators `=~#` or `=~?` instead of `=~` (see Google VimScript Style Guide (Matching))',
\ ])