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 " Description: opa check for rego files
3 call ale#Set('rego_opacheck_executable', 'opa')
4 call ale#Set('rego_opacheck_options', '')
6 function! ale_linters#rego#opacheck#GetExecutable(buffer) abort
7 return ale#Var(a:buffer, 'rego_opacheck_executable')
10 function! ale_linters#rego#opacheck#GetCommand(buffer) abort
11 let l:options = ale#Var(a:buffer, 'rego_opacheck_options')
13 return ale#Escape(ale_linters#rego#opacheck#GetExecutable(a:buffer))
14 \ . ' check %s:h --format json '
15 \ . (!empty(l:options) ? ' ' . l:options : '')
18 function! ale_linters#rego#opacheck#Handle(buffer, lines) abort
21 let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'errors': []})
22 let l:dir = expand('#' . a:buffer . ':p:h')
23 let l:file = expand('#' . a:buffer . ':p')
25 for l:error in l:errors['errors']
26 if has_key(l:error, 'location')
28 \ 'filename': ale#path#GetAbsPath(l:dir, l:error['location']['file']),
29 \ 'lnum': l:error['location']['row'],
30 \ 'col': l:error['location']['col'],
31 \ 'text': l:error['message'],
32 \ 'code': l:error['code'],
40 \ 'text': l:error['message'],
41 \ 'code': l:error['code'],
50 call ale#linter#Define('rego', {
52 \ 'output_stream': 'both',
53 \ 'executable': function('ale_linters#rego#opacheck#GetExecutable'),
54 \ 'command': function('ale_linters#rego#opacheck#GetCommand'),
55 \ 'callback': 'ale_linters#rego#opacheck#Handle',