summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2020-10-31 18:31:26 -0300
committerLeo <thinkabit.ukim@gmail.com>2021-01-22 14:04:26 -0300
commit99a809c814880e8e592e8150dc39fd7a5b584371 (patch)
tree529c8fcf578d2efec185aac51395ee7130e9999e
parent33f2f8ddcd9d934c6eef0dc3bf6c434d00aaa734 (diff)
downloadale-99a809c814880e8e592e8150dc39fd7a5b584371.zip
Add handler for the output of atools
atools is a collection of tools written in ash shell and Lua that provide linting for Alpine Linux's APKBUILD. APKBUILDs are build recipes used by Alpine Linux's build system, abuild, an equivalent would be Arch Linux's PKGBUILD and Gentoo's ebuild.
-rw-r--r--autoload/ale/handlers/atools.vim41
1 files changed, 41 insertions, 0 deletions
diff --git a/autoload/ale/handlers/atools.vim b/autoload/ale/handlers/atools.vim
new file mode 100644
index 00000000..c273fc40
--- /dev/null
+++ b/autoload/ale/handlers/atools.vim
@@ -0,0 +1,41 @@
+" Author: Leo <thinkabit.ukim@gmail.com>
+" Description: Handlers for output expected from atools
+
+function! ale#handlers#atools#Handle(buffer, lines) abort
+ " Format: SEVERITY:[TAG]:PATH:LINENUM:MSG
+ " Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install=
+ let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ " We are expected to receive 2 characters, the first character
+ " can be 'S', 'I', 'M' 'T', which are respectively:
+ " Serious (Error)
+ " Important (Error)
+ " Minor (Warning)
+ " Style (Warning)
+ "
+ " The second character can be either 'C' or 'P', which are respectively:
+ " Certain (Error)
+ " Possible (Warning)
+ let l:severity = matchstr(l:match[1], '^.')
+ let l:certainty = matchstr(l:match[1], '.$')
+
+ let l:type = 'E'
+ " If the tag returns 'Minor' or 'Style' or is 'Possible'
+ " then return a warning
+
+ if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P'
+ let l:type = 'W'
+ endif
+
+ call add(l:output, {
+ \ 'lnum': l:match[4] + 0,
+ \ 'text': l:match[5],
+ \ 'type': l:type,
+ \ 'code': matchstr(l:match[2], 'AL[0-9]*'),
+ \})
+ endfor
+
+ return l:output
+endfunction