summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2022-09-11 10:53:33 +0900
committerGitHub <noreply@github.com>2022-09-11 10:53:33 +0900
commita51fd9dababe43d239b8bdc1c10ac1f5397d6739 (patch)
tree1a5491d00b264710af0dd85b342edb068ecc5749 /ale_linters
parent9e8920b3362b1382cfe4bb6691f2bf4bf41e6e68 (diff)
downloadale-a51fd9dababe43d239b8bdc1c10ac1f5397d6739.zip
Add gitlablint support (#3042)
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/yaml/gitlablint.vim49
1 files changed, 49 insertions, 0 deletions
diff --git a/ale_linters/yaml/gitlablint.vim b/ale_linters/yaml/gitlablint.vim
new file mode 100644
index 00000000..ec48115a
--- /dev/null
+++ b/ale_linters/yaml/gitlablint.vim
@@ -0,0 +1,49 @@
+call ale#Set('yaml_gitlablint_executable', 'gll')
+call ale#Set('yaml_gitlablint_options', '')
+
+function! ale_linters#yaml#gitlablint#GetCommand(buffer) abort
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_gitlablint_options'))
+ \ . ' -p %t'
+endfunction
+
+function! ale_linters#yaml#gitlablint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ " (<unknown>): mapping values are not allowed in this context at line 68 column 8
+ " jobs:build:dev config contains unknown keys: ony
+ let l:pattern = '^\(.*\) at line \(\d\+\) column \(\d\+\)$'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if !empty(l:match)
+ let l:item = {
+ \ 'lnum': l:match[2] + 0,
+ \ 'col': l:match[3] + 0,
+ \ 'text': l:match[1],
+ \ 'type': 'E',
+ \}
+ call add(l:output, l:item)
+ else
+ if l:line isnot# 'GitLab CI configuration is invalid'
+ let l:item = {
+ \ 'lnum': 0,
+ \ 'col': 0,
+ \ 'text': l:line,
+ \ 'type': 'E',
+ \}
+ call add(l:output, l:item)
+ endif
+ endif
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('yaml', {
+\ 'name': 'gitlablint',
+\ 'executable': {b -> ale#Var(b, 'yaml_gitlablint_executable')},
+\ 'command': function('ale_linters#yaml#gitlablint#GetCommand'),
+\ 'callback': 'ale_linters#yaml#gitlablint#Handle',
+\ 'output_stream': 'stderr',
+\})