diff options
author | Bartek thindil Jasicki <thindil@laeran.pl> | 2021-01-08 09:43:19 +0100 |
---|---|---|
committer | Bartek thindil Jasicki <thindil@laeran.pl> | 2021-01-08 09:43:19 +0100 |
commit | 7b1ed2733e2b73a74149f300d5400225f535f490 (patch) | |
tree | b71be581af826a7f447b1c89897d7919106bf8df /ale_linters/salt | |
parent | 3fca5e73b605a07d3fdcf46cf24b1675aae5bca6 (diff) | |
parent | 54dd731cf14c809ebcc9c21b41084a17c5411744 (diff) | |
download | ale-7b1ed2733e2b73a74149f300d5400225f535f490.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'ale_linters/salt')
-rw-r--r-- | ale_linters/salt/salt_lint.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ale_linters/salt/salt_lint.vim b/ale_linters/salt/salt_lint.vim new file mode 100644 index 00000000..d2027119 --- /dev/null +++ b/ale_linters/salt/salt_lint.vim @@ -0,0 +1,32 @@ +" Author: Benjamin BINIER <poulpatine@gmail.com> +" Description: salt-lint, saltstack linter + +call ale#Set('salt_salt_lint_executable', 'salt-lint') +call ale#Set('salt_salt_lint_options', '') + +function! ale_linters#salt#salt_lint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options')) + \ . ' --json' +endfunction + +function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + call add(l:output, { + \ 'lnum': l:error.linenumber + 0, + \ 'code': l:error.id + 0, + \ 'text': l:error.message, + \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('salt', { +\ 'name': 'salt-lint', +\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')}, +\ 'command': function('ale_linters#salt#salt_lint#GetCommand'), +\ 'callback': 'ale_linters#salt#salt_lint#Handle' +\}) |