summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-05 12:45:36 +0900
committerGitHub <noreply@github.com>2021-01-05 12:45:36 +0900
commit7e4c125d38181a0e0d0c7883091e2fe683243ce4 (patch)
tree52f6287cd167ce757dc71b2448e41bbe47b78046 /ale_linters
parent8c34c738aba4ef2ff033b693037eec343f629b0e (diff)
parente358afdd9ba5108680afc6aa017075b44f6c18fa (diff)
downloadale-7e4c125d38181a0e0d0c7883091e2fe683243ce4.zip
Merge pull request #3491 from Poulpatine/salt-lint
Add salt-lint support
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/salt/salt_lint.vim32
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'
+\})