summaryrefslogtreecommitdiff
path: root/ale_linters/racket
diff options
context:
space:
mode:
authorAnthony Quizon <aqui18@users.noreply.github.com>2019-01-15 06:45:33 +1100
committerw0rp <w0rp@users.noreply.github.com>2019-01-14 19:45:33 +0000
commitd09e8bc99e870d15365b4ea556677b44527c41da (patch)
treebe6ca53bed69f0f6f8a80f7032916d966b53e45a /ale_linters/racket
parentc0b2090fbbc7a72dcf4963bf4d72cb6fc0b61e1d (diff)
downloadale-d09e8bc99e870d15365b4ea556677b44527c41da.zip
Racket linting using raco (#2146)
Diffstat (limited to 'ale_linters/racket')
-rw-r--r--ale_linters/racket/raco.vim33
1 files changed, 33 insertions, 0 deletions
diff --git a/ale_linters/racket/raco.vim b/ale_linters/racket/raco.vim
new file mode 100644
index 00000000..e5ee4fb4
--- /dev/null
+++ b/ale_linters/racket/raco.vim
@@ -0,0 +1,33 @@
+" Author: aqui18 <https://github.com/aqui18>
+" Description: This file adds support for checking Racket code with raco.
+" This is the same form of syntax-checking used by DrRacket as well. The
+" downside is that it will only catch the first error, but none of the
+" subsequent ones. This is due to how evaluation in Racket works.
+
+function! ale_linters#racket#raco#Handle(buffer, lines) abort
+ " Matches patterns
+ " <file>:<line>:<column> <message>
+ " eg:
+ " info.rkt:4:0: infotab-module: not a well-formed definition
+ let l:pattern = '^\(\s\)\@!\(.\+\):\(\d\+\):\(\d\+\): \(.\+\)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': l:match[3] + 0,
+ \ 'col': l:match[4] + 0,
+ \ 'type': 'E',
+ \ 'text': l:match[5],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('racket', {
+\ 'name': 'raco',
+\ 'executable': 'raco',
+\ 'output_stream': 'stderr',
+\ 'command': 'raco expand %s',
+\ 'callback': 'ale_linters#racket#raco#Handle',
+\})