summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/bicep/bicep.vim63
-rw-r--r--doc/ale-bicep.txt24
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/handler/test_bicep_bicep_handler.vader30
-rw-r--r--test/linter/test_bicep_bicep.vader21
7 files changed, 144 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',
+\})
diff --git a/doc/ale-bicep.txt b/doc/ale-bicep.txt
new file mode 100644
index 00000000..d26d67bc
--- /dev/null
+++ b/doc/ale-bicep.txt
@@ -0,0 +1,24 @@
+===============================================================================
+ALE Bicep Integration *ale-bicep-options*
+
+
+===============================================================================
+bicep *ale-bicep-bicep*
+
+g:ale_bicep_bicep_executable *g:ale_bicep_bicep_executable*
+ *b:ale_bicep_bicep_executable*
+ Type: |String|
+ Default: `'bicep'`
+
+ This variable can be set to change the path to bicep.
+
+
+g:ale_bicep_bicep_options *g:ale_bicep_bicep_options*
+ *b:ale_bicep_bicep_options*
+ Type: |String|
+ Default: `'build --outfile /dev/null'`
+
+ This variable can be set to pass additional options to bicep.
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index c7548f9f..080b7ec0 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -52,6 +52,8 @@ Notes:
* `buildifier`
* BibTeX
* `bibclean`
+* Bicep
+ * `bicep`
* BitBake
* `oelint-adv`
* Bourne Shell
diff --git a/doc/ale.txt b/doc/ale.txt
index ed3696d4..c20924be 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2787,6 +2787,8 @@ documented in additional help files.
buildifier............................|ale-bazel-buildifier|
bib.....................................|ale-bib-options|
bibclean..............................|ale-bib-bibclean|
+ bicep...................................|ale-bicep-options|
+ bicep.................................|ale-bicep-bicep|
bitbake.................................|ale-bitbake-options|
oelint-adv............................|ale-bitbake-oelint_adv|
c.......................................|ale-c-options|
diff --git a/supported-tools.md b/supported-tools.md
index 70896ca9..ed4458f1 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -61,6 +61,8 @@ formatting.
* [buildifier](https://github.com/bazelbuild/buildtools)
* BibTeX
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
+* Bicep
+ * [bicep](https://github.com/Azure/bicep)
* BitBake
* [oelint-adv](https://github.com/priv-kweihmann/oelint-adv)
* Bourne Shell
diff --git a/test/handler/test_bicep_bicep_handler.vader b/test/handler/test_bicep_bicep_handler.vader
new file mode 100644
index 00000000..d105cae5
--- /dev/null
+++ b/test/handler/test_bicep_bicep_handler.vader
@@ -0,0 +1,30 @@
+Before:
+ runtime ale_linters/bicep/bicep.vim
+
+After:
+ Restore
+
+ call ale#linter#Reset()
+
+Execute(The cmake_lint handler should handle basic warnings):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 7,
+ \ 'col': 10,
+ \ 'type': 'W',
+ \ 'code': 'no-unused-existing-resources',
+ \ 'text': 'Existing resource "asdasd" is declared but never used. [https://aka.ms/bicep/linter/no-unused-existing-resources]',
+ \ },
+ \ {
+ \ 'lnum': 106,
+ \ 'col': 6,
+ \ 'type': 'E',
+ \ 'code': 'BCP019',
+ \ 'text': 'Expected a new line character at this location.',
+ \ },
+ \ ],
+ \ ale_linters#bicep#bicep#Handle(1, [
+ \ '/tmp/nvimhxqs5D/1/dns.bicep(7,10) : Warning no-unused-existing-resources: Existing resource "asdasd" is declared but never used. [https://aka.ms/bicep/linter/no-unused-existing-resources]',
+ \ '/tmp/nvimhxqs5D/1/dns.bicep(106,6) : Error BCP019: Expected a new line character at this location.',
+ \ ])
diff --git a/test/linter/test_bicep_bicep.vader b/test/linter/test_bicep_bicep.vader
new file mode 100644
index 00000000..2beb2f22
--- /dev/null
+++ b/test/linter/test_bicep_bicep.vader
@@ -0,0 +1,21 @@
+Before:
+ call ale#assert#SetUpLinterTest('bicep', 'bicep')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ if has('win32')
+ AssertLinter 'bicep', ale#Escape('bicep') . ' build --outfile NUL %t'
+ else
+ AssertLinter 'bicep', ale#Escape('bicep') . ' build --outfile /dev/null %t'
+ endif
+
+Execute(The executable should be configurable):
+ let g:ale_bicep_bicep_executable = 'foobar'
+
+ if has('win32')
+ AssertLinter 'foobar', ale#Escape('foobar') . ' build --outfile NUL %t'
+ else
+ AssertLinter 'foobar', ale#Escape('foobar') . ' build --outfile /dev/null %t'
+ endif