summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Vereshchagin <dmitri.vereshchagin@gmail.com>2017-07-16 14:35:43 +0300
committerDmitri Vereshchagin <dmitri.vereshchagin@gmail.com>2017-07-16 15:35:21 +0300
commit1aea6a34ff22c9e79d20a018b4d46000c208caf2 (patch)
treed82ef31ee8e65c187414b642adeaed442e80c422
parent4fa66ab627039fe19cf6383b19d311066b73d8cf (diff)
downloadale-1aea6a34ff22c9e79d20a018b4d46000c208caf2.zip
Add SyntaxErl linter
These changes add [SyntaxErl][1] integration. SyntaxErl is a syntax checker tool for Erlang. [1]: https://github.com/ten0s/syntaxerl
-rw-r--r--README.md2
-rw-r--r--ale_linters/erlang/syntaxerl.vim38
-rw-r--r--doc/ale-erlang.txt11
-rw-r--r--doc/ale.txt1
-rw-r--r--test/handler/test_syntaxerl_handler.vader24
5 files changed, 75 insertions, 1 deletions
diff --git a/README.md b/README.md
index 38ad43e3..6a66e95d 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ name. That seems to be the fairest way to arrange this table.
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) |
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
| Erb | [erb](https://github.com/jeremyevans/erubi) |
-| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |
+| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
| Fortran | [gcc](https://gcc.gnu.org/) |
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
| Go | [gofmt -e](https://golang.org/cmd/gofmt/), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [gometalinter](https://github.com/alecthomas/gometalinter), [go build](https://golang.org/cmd/go/), [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple), [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) |
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim
new file mode 100644
index 00000000..dd53d8e8
--- /dev/null
+++ b/ale_linters/erlang/syntaxerl.vim
@@ -0,0 +1,38 @@
+" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
+" Description: SyntaxErl linter for Erlang files
+
+call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
+
+
+function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
+endfunction
+
+
+function! ale_linters#erlang#syntaxerl#GetCommand(buffer) abort
+ return ale_linters#erlang#syntaxerl#GetExecutable(a:buffer) . ' %t'
+endfunction
+
+
+function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
+ let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
+ let l:loclist = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:loclist, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'text': l:match[3],
+ \ 'type': empty(l:match[2]) ? 'E' : 'W',
+ \})
+ endfor
+
+ return l:loclist
+endfunction
+
+
+call ale#linter#Define('erlang', {
+\ 'name': 'syntaxerl',
+\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable',
+\ 'command_callback': 'ale_linters#erlang#syntaxerl#GetCommand',
+\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
+\})
diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt
index 9e44623f..ad3c1e5a 100644
--- a/doc/ale-erlang.txt
+++ b/doc/ale-erlang.txt
@@ -14,5 +14,16 @@ g:ale_erlang_erlc_options *g:ale_erlang_erlc_options*
or `-pa`.
+-------------------------------------------------------------------------------
+syntaxerl *ale-erlang-syntaxerl*
+
+g:ale_erlang_syntaxerl_executable *g:ale_erlang_syntaxerl_executable*
+ *b:ale_erlang_syntaxerl_executable*
+ Type: |String|
+ Default: `'syntaxerl'`
+
+ This variable can be changed to specify the syntaxerl executable.
+
+
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 642d3883..9ebe8a6b 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -33,6 +33,7 @@ CONTENTS *ale-contents*
cmakelint...........................|ale-cmake-cmakelint|
erlang................................|ale-erlang-options|
erlc................................|ale-erlang-erlc|
+ syntaxerl...........................|ale-erlang-syntaxerl|
fortran...............................|ale-fortran-options|
gcc.................................|ale-fortran-gcc|
fusionscript..........................|ale-fuse-options|
diff --git a/test/handler/test_syntaxerl_handler.vader b/test/handler/test_syntaxerl_handler.vader
new file mode 100644
index 00000000..1308ec84
--- /dev/null
+++ b/test/handler/test_syntaxerl_handler.vader
@@ -0,0 +1,24 @@
+Before:
+ runtime ale_linters/erlang/syntaxerl.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute:
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 42,
+ \ 'text': "syntax error before: ','",
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 42,
+ \ 'text': 'function foo/0 is unused',
+ \ 'type': 'W',
+ \ },
+ \ ],
+ \ ale_linters#erlang#syntaxerl#Handle(42, [
+ \ "/tmp/v2wDixk/1/module.erl:42: syntax error before: ','",
+ \ '/tmp/v2wDixk/2/module.erl:42: warning: function foo/0 is unused',
+ \ ])