]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/bitbake/oelint_adv.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / bitbake / oelint_adv.vim
1 " Author: offa
2 " Description: oelint-adv for BitBake files
3
4 call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv')
5 call ale#Set('bitbake_oelint_adv_options', '')
6 call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg')
7
8 function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
9     let l:config_file = ale#path#FindNearestFile(a:buffer,
10     \    ale#Var(a:buffer, 'bitbake_oelint_adv_config'))
11
12     return ((!empty(l:config_file))
13     \    ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' '
14     \    : '')
15     \    . '%e --quiet '
16     \    . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) .  '%s'
17 endfunction
18
19 function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
20     let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$'
21     let l:output = []
22
23     for l:match in ale#util#GetMatches(a:lines, l:pattern)
24         call add(l:output, {
25         \    'lnum': str2nr(l:match[2]),
26         \    'type': l:match[3] is# 'error'
27         \          ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
28         \    'text': StripAnsiCodes(l:match[5]),
29         \    'code': l:match[4]
30         \    })
31     endfor
32
33     return l:output
34 endfunction
35
36 function! StripAnsiCodes(line) abort
37     return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
38 endfunction
39
40 call ale#linter#Define('bitbake', {
41 \    'name': 'oelint_adv',
42 \    'output_stream': 'both',
43 \    'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')},
44 \    'cwd': '%s:h',
45 \    'command': function('ale_linters#bitbake#oelint_adv#Command'),
46 \    'callback': 'ale_linters#bitbake#oelint_adv#Handle',
47 \    })