summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorCarl Smedstad <carl.smedstad@protonmail.com>2022-09-14 01:13:41 +0200
committerGitHub <noreply@github.com>2022-09-14 08:13:41 +0900
commit8e03ceecdc4151b6a85c004ce4ef699da0a1f57a (patch)
tree6f4df01e268eb985f7dd144b4edf3e9cd1539ceb /ale_linters
parent77fcf9b2c270dd2c97fd175dbabed79a84114690 (diff)
downloadale-8e03ceecdc4151b6a85c004ce4ef699da0a1f57a.zip
Add support for Microsoft's DSL Bicep (#4310)
* Add support for Microsoft's DSL Bicep The compilation command 'bicep build' catches compilation errors as well as providing some lint warnings. Repository for Bicep: https://github.com/Azure/bicep * Different null file on Windows & hardcode commands
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/bicep/bicep.vim63
1 files changed, 63 insertions, 0 deletions
diff --git a/ale_linters/bicep/bicep.vim b/ale_linters/bicep/bicep.vim
new file mode 100644
index 00000000..5796f83e
--- /dev/null
+++ b/ale_linters/bicep/bicep.vim
@@ -0,0 +1,63 @@
+" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
+" Description: bicep for bicep files
+
+let g:ale_bicep_bicep_executable =
+\ get(g:, 'ale_bicep_bicep_executable', 'bicep')
+
+let g:ale_bicep_bicep_options =
+\ get(g:, 'ale_bicep_bicep_options', '')
+
+function! ale_linters#bicep#bicep#Executable(buffer) abort
+ return ale#Var(a:buffer, 'bicep_bicep_executable')
+endfunction
+
+function! ale_linters#bicep#bicep#Command(buffer) abort
+ let l:executable = ale_linters#bicep#bicep#Executable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'bicep_bicep_options')
+
+ if has('win32')
+ let l:nullfile = 'NUL'
+ else
+ let l:nullfile = '/dev/null'
+ endif
+
+ return ale#Escape(l:executable)
+ \ . ' build --outfile '
+ \ . l:nullfile
+ \ . ' '
+ \ . l:options
+ \ . ' %t'
+endfunction
+
+function! ale_linters#bicep#bicep#Handle(buffer, lines) abort
+ let l:pattern = '\v^.*\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ if l:match[3] is# 'Error'
+ let l:type = 'E'
+ elseif l:match[3] is# 'Warning'
+ let l:type = 'W'
+ else
+ let l:type = 'I'
+ endif
+
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'type': l:type,
+ \ 'code': l:match[4],
+ \ 'text': l:match[5],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('bicep', {
+\ 'name': 'bicep',
+\ 'executable': function('ale_linters#bicep#bicep#Executable'),
+\ 'command': function('ale_linters#bicep#bicep#Command'),
+\ 'callback': 'ale_linters#bicep#bicep#Handle',
+\ 'output_stream': 'both',
+\})