diff --git a/README.md b/README.md index cb374d81..e11984c9 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ name. That seems to be the fairest way to arrange this table. | Erlang | [erlc](http://erlang.org/doc/man/erlc.html) | | Fortran | [gcc](https://gcc.gnu.org/) | | Go | [gofmt -e](https://golang.org/cmd/gofmt/), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [go build](https://golang.org/cmd/go/) | +| Haml | [haml-lint](https://github.com/brigade/haml-lint) | Haskell | [ghc](https://www.haskell.org/ghc/), [hlint](https://hackage.haskell.org/package/hlint) | | 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) | diff --git a/ale_linters/haml/hamllint.vim b/ale_linters/haml/hamllint.vim new file mode 100644 index 00000000..fead7472 --- /dev/null +++ b/ale_linters/haml/hamllint.vim @@ -0,0 +1,33 @@ +" Author: Patrick Lewis - https://github.com/patricklewis +" Description: haml-lint for Haml files + +function! ale_linters#haml#hamllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " :51 [W] RuboCop: Use the new Ruby 1.9 hash syntax. + let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2], + \ 'text': l:match[3] + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('haml', { +\ 'name': 'hamllint', +\ 'executable': 'haml-lint', +\ 'command': 'haml-lint %t', +\ 'callback': 'ale_linters#haml#hamllint#Handle' +\}) diff --git a/doc/ale.txt b/doc/ale.txt index af26b9c9..734c389c 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -91,6 +91,7 @@ The following languages and tools are supported. * Erlang: 'erlc' * Fortran: 'gcc' * Go: 'gofmt -e', 'go vet', 'golint', 'go build' +* Haml: 'hamllint' * Haskell: 'ghc', 'hlint' * HTML: 'HTMLHint', 'proselint', 'tidy' * Java: 'javac'