]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/ruby.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / handlers / ruby.vim
1 " Author: Brandon Roehl - https://github.com/BrandonRoehl, Matthias Guenther https://wikimatze.de
2 "
3 " Description: This file implements handlers specific to Ruby.
4
5 function! s:HandleSyntaxError(buffer, lines) abort
6     " Matches patterns line the following:
7     "
8     " test.rb:3: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
9     " test.rb:8: syntax error, unexpected keyword_end, expecting end-of-input
10     let l:pattern = '\v^.+:(\d+): (warning: )?(.+)$'
11     let l:column = '\v^(\s+)\^$'
12     let l:output = []
13
14     for l:line in a:lines
15         let l:match = matchlist(l:line, l:pattern)
16
17         if len(l:match) == 0
18             let l:match = matchlist(l:line, l:column)
19
20             if len(l:match) != 0
21                 let l:output[len(l:output) - 1]['col'] = len(l:match[1])
22             endif
23         else
24             call add(l:output, {
25             \   'lnum': l:match[1] + 0,
26             \   'col': 0,
27             \   'text': l:match[2] . l:match[3],
28             \   'type': empty(l:match[2]) ? 'E' : 'W',
29             \})
30         endif
31     endfor
32
33     return l:output
34 endfunction
35
36 function! ale#handlers#ruby#HandleSyntaxErrors(buffer, lines) abort
37     return s:HandleSyntaxError(a:buffer, a:lines)
38 endfunction