summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/racket/raco.vim33
-rw-r--r--test/command_callback/test_racket_raco_command_callback.vader10
-rw-r--r--test/handler/test_raco_handler.vader26
3 files changed, 69 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',
+\})
diff --git a/test/command_callback/test_racket_raco_command_callback.vader b/test/command_callback/test_racket_raco_command_callback.vader
new file mode 100644
index 00000000..fb83ffa1
--- /dev/null
+++ b/test/command_callback/test_racket_raco_command_callback.vader
@@ -0,0 +1,10 @@
+Before:
+ call ale#assert#SetUpLinterTest('racket', 'raco')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command and executable should be correct):
+ AssertLinter 'raco', 'raco expand %s'
+
+
diff --git a/test/handler/test_raco_handler.vader b/test/handler/test_raco_handler.vader
new file mode 100644
index 00000000..217fe2f9
--- /dev/null
+++ b/test/handler/test_raco_handler.vader
@@ -0,0 +1,26 @@
+Before:
+ runtime ale_linters/racket/raco.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The raco handler should handle errors for the current file correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 4,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'dfine: unbound identifier in modulemessage',
+ \ },
+ \ ],
+ \ ale_linters#racket#raco#Handle(bufnr(''), [
+ \ 'foo.rkt:4:1: dfine: unbound identifier in modulemessage',
+ \ ' in: dfine',
+ \ ' context...:',
+ \ ' /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:34:15: loop',
+ \ ' /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:10:2: show-program',
+ \ ' /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt: [running body]',
+ \ ' /usr/local/Cellar/minimal-racket/6.6/share/racket/collects/raco/raco.rkt: [running body]',
+ \ ' /usr/local/Cellar/minimal-racket/6.6/share/racket/collects/raco/main.rkt: [running body]',
+ \ ])