summaryrefslogtreecommitdiff
path: root/ale_linters/yaml/actionlint.vim
diff options
context:
space:
mode:
authorPeter Benjamin <petermbenjamin@gmail.com>2023-09-05 06:33:41 -0700
committerGitHub <noreply@github.com>2023-09-05 14:33:41 +0100
commit3bedafc29a45d478f41d8467a988e29c35618737 (patch)
tree36d0cead8c4b78063cbed5a41538ea9d3855944a /ale_linters/yaml/actionlint.vim
parent115ad17ace047cab20ccc67f79c943aaf3f0f291 (diff)
downloadale-3bedafc29a45d478f41d8467a988e29c35618737.zip
fix(yaml): make actionlint respect config (#4584)
* fix(yaml): make actionlint respect config * docs: update actionlint docs * chore: update author & add description * test: move actionlint test to test/linter/
Diffstat (limited to 'ale_linters/yaml/actionlint.vim')
-rw-r--r--ale_linters/yaml/actionlint.vim42
1 files changed, 39 insertions, 3 deletions
diff --git a/ale_linters/yaml/actionlint.vim b/ale_linters/yaml/actionlint.vim
index 1e2fda49..75fe3162 100644
--- a/ale_linters/yaml/actionlint.vim
+++ b/ale_linters/yaml/actionlint.vim
@@ -1,11 +1,47 @@
-" Author: bretello <bretello@distruzione.org>
+" Author: Peter Benjamin <petermbenjamin@gmail.com>
+" Description: Linter for GitHub Workflows
call ale#Set('yaml_actionlint_executable', 'actionlint')
call ale#Set('yaml_actionlint_options', '')
+function! ale_linters#yaml#actionlint#GetCommand(buffer) abort
+ let l:options = ale#Var(a:buffer, 'yaml_actionlint_options')
+
+ if l:options !~# '-no-color'
+ let l:options .= ale#Pad('-no-color')
+ endif
+
+ if l:options !~# '-oneline'
+ let l:options .= ale#Pad('-oneline')
+ endif
+
+ return '%e' . ale#Pad(l:options)
+endfunction
+
+function! ale_linters#yaml#actionlint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ ".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax]
+ let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:item = {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'text': l:match[3],
+ \ 'code': l:match[4],
+ \ 'type': 'E',
+ \}
+
+ call add(l:output, l:item)
+ endfor
+
+ return l:output
+endfunction
+
call ale#linter#Define('yaml', {
\ 'name': 'actionlint',
\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')},
-\ 'command': function('ale#handlers#actionlint#GetCommand'),
-\ 'callback': 'ale#handlers#actionlint#Handle',
+\ 'command': function('ale_linters#yaml#actionlint#GetCommand'),
+\ 'callback': 'ale_linters#yaml#actionlint#Handle',
\})