summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2017-04-15 11:34:20 +0100
committerGitHub <noreply@github.com>2017-04-15 11:34:20 +0100
commitd5ccb1a7a16a325d88f01f8a1de619ef340e1885 (patch)
treef166feac12036b4f3d05c0d0ead052dd7d627eea /ale_linters
parent8351bdbc066ed7f56bf78f4286565652e4a207ed (diff)
parentabdfaaf84fad4cc745eb601545af669b1833c0a9 (diff)
downloadale-d5ccb1a7a16a325d88f01f8a1de619ef340e1885.zip
Merge pull request #474 from jordanandree/add-crystal-lint
Add linter for Crystal lang
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/crystal/crystal.vim40
1 files changed, 40 insertions, 0 deletions
diff --git a/ale_linters/crystal/crystal.vim b/ale_linters/crystal/crystal.vim
new file mode 100644
index 00000000..5abf7e84
--- /dev/null
+++ b/ale_linters/crystal/crystal.vim
@@ -0,0 +1,40 @@
+" Author: Jordan Andree <https://github.com/jordanandree>
+" Description: This file adds support for checking Crystal with crystal build
+
+function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
+ let l:output = []
+
+ let l:lines = join(a:lines, '')
+
+ if !empty(l:lines)
+ let l:errors = json_decode(l:lines)
+
+ for l:error in l:errors
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': l:error.line + 0,
+ \ 'col': l:error.column + 0,
+ \ 'text': l:error.message,
+ \ 'type': 'E',
+ \})
+ endfor
+ endif
+
+ return l:output
+endfunction
+
+function! ale_linters#crystal#crystal#GetCommand(buffer) abort
+ let l:crystal_cmd = 'crystal build -f json --no-codegen -o '
+ let l:crystal_cmd .= shellescape(g:ale#util#nul_file)
+ let l:crystal_cmd .= ' %t'
+
+ return l:crystal_cmd
+endfunction
+
+call ale#linter#Define('crystal', {
+\ 'name': 'crystal',
+\ 'executable': 'crystal',
+\ 'output_stream': 'both',
+\ 'command_callback': 'ale_linters#crystal#crystal#GetCommand',
+\ 'callback': 'ale_linters#crystal#crystal#Handle',
+\})