diff options
author | Jon Parise <jon@indelible.org> | 2021-08-03 17:29:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 09:29:07 +0900 |
commit | 2dd9790281b8fa8e31b664629ecbb06de46c5a70 (patch) | |
tree | dc5bd1661f56fcce4703f977f1d396add819c616 /ale_linters | |
parent | fa032b1b7fde1cb00bfa3e16a0d3ebd37a7d8be4 (diff) | |
download | ale-2dd9790281b8fa8e31b664629ecbb06de46c5a70.zip |
Add a thriftcheck linter (#3852)
ThriftCheck (https://github.com/pinterest/thriftcheck) is a linter for
Thrift IDL files.
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/thrift/thriftcheck.vim | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ale_linters/thrift/thriftcheck.vim b/ale_linters/thrift/thriftcheck.vim new file mode 100644 index 00000000..7b8cbee1 --- /dev/null +++ b/ale_linters/thrift/thriftcheck.vim @@ -0,0 +1,46 @@ +" Author: Jon Parise <jon@indelible.org> + +call ale#Set('thrift_thriftcheck_executable', 'thriftcheck') +call ale#Set('thrift_thriftcheck_options', '') + +function! ale_linters#thrift#thriftcheck#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thriftcheck_options')) + \ . ' --stdin-filename %s' + \ . ' %t' +endfunction + +function! ale_linters#thrift#thriftcheck#Handle(buffer, lines) abort + " Matches lines like the following: + " + " file.thrift:1:1:error: "py" namespace must match "^idl\\." (namespace.pattern) + " file.thrift:3:5:warning: 64-bit integer constant -2147483649 may not work in all languages (int.64bit) + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):(\l+): (.*) \((.*)\)$' + + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('thrift', { +\ 'name': 'thriftcheck', +\ 'executable': {b -> ale#Var(b, 'thrift_thriftcheck_executable')}, +\ 'command': function('ale_linters#thrift#thriftcheck#GetCommand'), +\ 'callback': 'ale_linters#thrift#thriftcheck#Handle', +\}) |