summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorZefei Xuan <zefei.xuan@gmail.com>2017-01-04 09:07:21 -0800
committerw0rp <w0rp@users.noreply.github.com>2017-01-04 17:07:21 +0000
commit5a0c3fd01e79feb1b35e554c38045ae0a88c429f (patch)
tree2e5df09b9a4a3ed8956190321886ace9101c399f /ale_linters
parented43b17201307bf1562624fbf6ddf93f4d0c93c3 (diff)
downloadale-5a0c3fd01e79feb1b35e554c38045ae0a88c429f.zip
Added hack linter for php (#239)
* added hack linter * updated docs for hack (hh_client) * naming
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/php/hack.vim37
1 files changed, 37 insertions, 0 deletions
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',
+\})