summaryrefslogtreecommitdiff
path: root/ale_linters/yaml
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-06-19 10:34:57 +0100
committerw0rp <devw0rp@gmail.com>2021-06-19 10:34:57 +0100
commit84a4a76aafaefe125df785ebac2e4858ec54debb (patch)
tree91797d6d9509a2439948ed6e60174a8f94ffb6ce /ale_linters/yaml
parent1b08791228f5aca4545a3fba6699b29a003028fe (diff)
downloadale-84a4a76aafaefe125df785ebac2e4858ec54debb.zip
Close #3770 - Add support for checking circleci configs
Diffstat (limited to 'ale_linters/yaml')
-rw-r--r--ale_linters/yaml/circleci.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/yaml/circleci.vim b/ale_linters/yaml/circleci.vim
new file mode 100644
index 00000000..3df61459
--- /dev/null
+++ b/ale_linters/yaml/circleci.vim
@@ -0,0 +1,35 @@
+function! ale_linters#yaml#circleci#Handle(buffer, lines) abort
+ let l:match_index = -1
+ let l:output = []
+
+ for l:index in range(len(a:lines))
+ let l:line = a:lines[l:index]
+
+ if l:line =~? 'Error: ERROR IN CONFIG FILE:'
+ let l:match_index = l:index + 1
+ break
+ endif
+ endfor
+
+ if l:match_index > 0
+ return [{
+ \ 'type': 'E',
+ \ 'lnum': 1,
+ \ 'text': a:lines[l:match_index],
+ \ 'detail': join(a:lines[l:match_index :], "\n"),
+ \}]
+ endif
+
+ return []
+endfunction
+
+" The circleci validate requires network requests, so we'll only run it when
+" files are saved to prevent the server from being hammered.
+call ale#linter#Define('yaml', {
+\ 'name': 'circleci',
+\ 'executable': {b -> expand('#' . b . ':p') =~? '\.circleci' ? 'circleci' : ''},
+\ 'command': 'circleci config validate - < %s',
+\ 'callback': 'ale_linters#yaml#circleci#Handle',
+\ 'output_stream': 'stderr',
+\ 'lint_file': 1,
+\})