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.
2 " Description: This file defines a handler function for linting OpenSCAD files
5 function! ale#handlers#openscad#SCA2D_callback(buffer, lines) abort
7 " foo.scad:3:1: W2001: Variable `unused` overwritten within scope.
8 " foo.scad:1:1: F0001: Cannot read file due to syntax error:
9 " - No terminal matches '}' in the current parser context, at line 1 col 36
10 let l:filename_re = '^\([^:]*\):'
11 let l:linenum_re = '\([0-9]*\):'
12 let l:colnum_re = '\([0-9]*\):'
13 let l:err_id = '\([IWEFU][0-9]\+\):'
14 let l:err_msg = '\(.*\)'
15 let l:pattern = filename_re .
27 let l:matches = matchlist(line, pattern)
30 " option: Info, Warning, Error, Fatal, Unknown
31 if index(['I', 'W'], matches[4][0]) >= 0
37 let l:lnum = matches[2]
38 let l:col = matches[3]
39 let l:text = matches[5]
41 " Better locations for some syntax errors
42 if matches[4][0] is# 'F'
43 let l:syntax_error_re = '^\(.*\), at line \([0-9]\+\) col \([0-9]\+\)$'
44 let l:next_line = a:lines[idx+1]
45 let l:syn_err_matches = matchlist(l:next_line, l:syntax_error_re)
47 if len(syn_err_matches) > 0
48 let l:text = l:text . l:syn_err_matches[1]
49 let l:lnum = l:syn_err_matches[2]
50 let l:col = l:syn_err_matches[3]
52 let l:text = l:next_line
57 \ 'lnum': str2nr(l:lnum),
58 \ 'col': str2nr(l:col),
60 \ 'detail': l:matches[4] . ': ' . l:text,
61 \ 'filename': fnamemodify(matches[1], ':p'),
65 call add(l:result, l:element)