diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ale_linters/php/hack.vim | 37 | ||||
-rw-r--r-- | doc/ale.txt | 2 |
3 files changed, 39 insertions, 2 deletions
@@ -72,7 +72,7 @@ name. That seems to be the fairest way to arrange this table. | MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) | | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-ocaml-merlin` for configuration instructions | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | -| PHP | [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | +| PHP | [hack](http://hacklang.org/), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | | Pug | [pug-lint](https://github.com/pugjs/pug-lint) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | | Python | [flake8](http://flake8.pycqa.org/en/latest/), [pylint](https://www.pylint.org/) | diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim new file mode 100644 index 00000000..bacd835d --- /dev/null +++ b/ale_linters/php/hack.vim @@ -0,0 +1,37 @@ +" Author: Zefei Xuan <https://github.com/zefei> +" Description: Hack type checking (http://hacklang.org/) + +function! ale_linters#php#hack#Handle(buffer, lines) + let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + if a:buffer != bufnr(l:match[1]) + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[2] + 0, + \ 'vcol': 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'hack', +\ 'executable': 'hh_client', +\ 'command': 'hh_client --retries 0 --retry-if-init false', +\ 'callback': 'ale_linters#php#hack#Handle', +\}) diff --git a/doc/ale.txt b/doc/ale.txt index 2ddb3d37..7fa9dac5 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -84,7 +84,7 @@ The following languages and tools are supported. * MATLAB: 'mlint' * OCaml: 'merlin' (see |ale-linter-integration-ocaml-merlin|) * Perl: 'perl' (-c flag), 'perlcritic' -* PHP: 'php' (-l flag), 'phpcs' +* PHP: 'hack', 'php' (-l flag), 'phpcs' * Pug: 'pug-lint' * Puppet: 'puppet', 'puppet-lint' * Python: 'flake8', 'pylint' |