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.
1 " Author:Travis Gibson <https://github.com/Garland-g>
2 " Description: This file adds support for checking perl6 syntax
4 let g:ale_perl6_perl6_executable =
5 \ get(g:, 'ale_perl6_perl6_executable', 'perl6')
7 let g:ale_perl6_perl6_options =
8 \ get(g:, 'ale_perl6_perl6_options', '-c -Ilib')
10 let $PERL6_EXCEPTIONS_HANDLER = 'JSON'
12 let $RAKUDO_ERROR_COLOR = 0
14 function! ale_linters#perl6#perl6#GetExecutable(buffer) abort
15 return ale#Var(a:buffer, 'perl6_perl6_executable')
18 function! ale_linters#perl6#perl6#GetCommand(buffer) abort
19 return ale_linters#perl6#perl6#GetExecutable(a:buffer)
20 \ . ' ' . ale#Var(a:buffer, 'perl6_perl6_options')
24 function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort
32 let l:linepatternmessage = 'at\s\+line\s\+\(\d\+\)'
34 if has_key(a:dict[a:item], 'filename') && !empty(a:dict[a:item]['filename'])
35 let l:file = a:dict[a:item]['filename']
38 if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line'])
39 let l:line = a:dict[a:item]['line']
43 if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column'])
44 let l:column = a:dict[a:item]['column']
47 if has_key(a:dict[a:item], 'message') && !empty(a:dict[a:item]['message'])
48 let l:text = substitute(a:dict[a:item]['message'], '\s*\n\s*', ' ', 'g')
52 if has_key(a:dict[a:item], 'line-real') && !empty(a:dict[a:item]['line-real'])
53 let l:end_line = l:line
54 let l:line = a:dict[a:item]['line-real']
57 for l:match in ale#util#GetMatches(l:text, l:linepatternmessage)
58 let l:line = l:match[1]
62 " Currently, filenames and line numbers are not always given in the error output
64 \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' )
66 \ 'lnum': '' . l:line,
70 \ 'end_lnum': l:end_line,
78 function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
85 if a:lines[0] is# 'Syntax OK'
90 let l:json = json_decode(join(a:lines, ''))
94 \ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details',
95 \ 'detail': join(a:lines, "\n"),
102 if type(l:json) is v:t_dict
103 for l:key in keys(l:json)
104 if has_key(l:json[l:key], 'sorrows')
105 \&& has_key(l:json[l:key], 'worries')
106 if !empty(l:json[l:key]['sorrows'])
107 for l:dictionary in get(l:json[l:key], 'sorrows')
108 for l:item in keys(l:dictionary)
110 \ ale_linters#perl6#perl6#ExtractError(
117 if l:result isnot# ''
118 call add(l:output, l:result)
124 if !empty(l:json[l:key]['worries'])
125 for l:dictionary in get(l:json[l:key], 'worries')
126 for l:item in keys(l:dictionary)
128 \ ale_linters#perl6#perl6#ExtractError(
135 if l:result isnot# ''
136 call add(l:output, l:result)
142 let l:result = ale_linters#perl6#perl6#ExtractError(
149 if l:result isnot# ''
150 call add(l:output, l:result)
159 call ale#linter#Define('perl6', {
161 \ 'executable': function('ale_linters#perl6#perl6#GetExecutable'),
162 \ 'output_stream': 'both',
163 \ 'command': function('ale_linters#perl6#perl6#GetCommand'),
164 \ 'callback': 'ale_linters#perl6#perl6#Handle',