summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorBrandon Roehl <SkyGuy913@gmail.com>2017-04-08 05:24:20 -0500
committerw0rp <w0rp@users.noreply.github.com>2017-04-08 11:24:20 +0100
commit4e40e8cb608fef9b088e6712d83f4fc3dccd5e77 (patch)
tree270316220de5e547f2fe7f3f565ffb2f3f2b2a5c /ale_linters
parentcc8eb0586043f1fcec73595c8a43d895a4753a05 (diff)
downloadale-4e40e8cb608fef9b088e6712d83f4fc3dccd5e77.zip
Add Ruby MRI linter (#453)
* Added ruby mri linter * Added to the list of supported linters * Async and now with 4 spaces * Vader tests for ruby * Match style choices * Vader test for the Ruby handler now works and passes
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/ruby/ruby.vim40
1 files changed, 40 insertions, 0 deletions
diff --git a/ale_linters/ruby/ruby.vim b/ale_linters/ruby/ruby.vim
new file mode 100644
index 00000000..7cffcf3a
--- /dev/null
+++ b/ale_linters/ruby/ruby.vim
@@ -0,0 +1,40 @@
+" Author: Brandon Roehl - https://github.com/BrandonRoehl
+" Description: Ruby MRI for Ruby files
+
+function! ale_linters#ruby#ruby#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ "
+ " test.rb:3: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
+ " test.rb:8: syntax error, unexpected keyword_end, expecting end-of-input
+ let l:pattern = '\v^.+:(\d+): (warning: )?(.+)$'
+ let l:column = '\v^(\s+)\^$'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+ if len(l:match) == 0
+ let l:match = matchlist(l:line, l:column)
+ if len(l:match) != 0
+ let l:output[len(l:output) - 1]['col'] = len(l:match[1])
+ endif
+ else
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': 0,
+ \ 'text': l:match[2] . l:match[3],
+ \ 'type': empty(l:match[2]) ? 'E' : 'W',
+ \})
+ endif
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('ruby', {
+\ 'name': 'ruby',
+\ 'executable': 'ruby',
+\ 'output_stream': 'stderr',
+\ 'command': 'ruby -w -c -T1 %t',
+\ 'callback': 'ale_linters#ruby#ruby#Handle',
+\})