]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/ale_linters/yaml/gitlablint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / yaml / gitlablint.vim
diff --git a/.vim/bundle/ale/ale_linters/yaml/gitlablint.vim b/.vim/bundle/ale/ale_linters/yaml/gitlablint.vim
new file mode 100644 (file)
index 0000000..ec48115
--- /dev/null
@@ -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',
+\})