summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwisut hantanong <wizzup@gmail.com>2017-04-22 19:23:23 +0700
committerw0rp <devw0rp@gmail.com>2017-05-15 19:46:02 +0100
commit3f33dc7d9832b7aed085d44b8ef76fd1c1eb90a5 (patch)
treead8beb01dda1bb5b56a6881bfd65c3ef3d3dd6e3
parentd4466d4be744d7723dc740b29faded1d685f091d (diff)
downloadale-3f33dc7d9832b7aed085d44b8ef76fd1c1eb90a5.zip
Haskell: add ghc-mod linter
-rw-r--r--README.md2
-rw-r--r--ale_linters/haskell/ghc-mod.vim16
-rw-r--r--doc/ale.txt2
-rw-r--r--test/handler/test_ghc_mod_handler.vader27
4 files changed, 45 insertions, 2 deletions
diff --git a/README.md b/README.md
index d3fb431e..d824a140 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@ name. That seems to be the fairest way to arrange this table.
| 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) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint)
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
-| Haskell | [ghc](https://www.haskell.org/ghc/), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) |
+| Haskell | [ghc](https://www.haskell.org/ghc/), [ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) |
| HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) |
| Java | [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
diff --git a/ale_linters/haskell/ghc-mod.vim b/ale_linters/haskell/ghc-mod.vim
new file mode 100644
index 00000000..d3d23649
--- /dev/null
+++ b/ale_linters/haskell/ghc-mod.vim
@@ -0,0 +1,16 @@
+" Author: wizzup <wizzup@gmail.com>
+" Description: ghc-mod for Haskell files
+
+call ale#linter#Define('haskell', {
+\ 'name': 'ghc-mod',
+\ 'executable': 'ghc-mod',
+\ 'command': 'ghc-mod check %t',
+\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
+\})
+
+call ale#linter#Define('haskell', {
+\ 'name': 'stack-ghc-mod',
+\ 'executable': 'stack',
+\ 'command': 'stack exec ghc-mod check %t',
+\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
+\})
diff --git a/doc/ale.txt b/doc/ale.txt
index d4d75173..c5411fc9 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -136,7 +136,7 @@ The following languages and tools are supported.
* Go: 'gofmt', 'go vet', 'golint', 'go build', 'gosimple', 'staticcheck'
* Haml: 'hamllint'
* Handlebars: 'ember-template-lint'
-* Haskell: 'ghc', 'hlint', 'hdevtools'
+* Haskell: 'ghc', 'ghc-mod', 'hlint', 'hdevtools'
* HTML: 'HTMLHint', 'proselint', 'tidy'
* Java: 'javac'
* JavaScript: 'eslint', 'jscs', 'jshint', 'flow', 'xo'
diff --git a/test/handler/test_ghc_mod_handler.vader b/test/handler/test_ghc_mod_handler.vader
new file mode 100644
index 00000000..f9b44b33
--- /dev/null
+++ b/test/handler/test_ghc_mod_handler.vader
@@ -0,0 +1,27 @@
+Execute(HandleGhcFormat should handle ghc-mod problems):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.',
+ \ },
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': ' Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...',
+ \ },
+ \ {
+ \ 'lnum': 6,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': ' Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ',
+ \ },
+ \ ],
+ \ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
+ \ 'check1.hs:2:1:Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.',
+ \ 'check2.hs:2:1: Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...',
+ \ 'check2.hs:6:1: Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ',
+ \ ])