summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authoroffa <bm-dev@yandex.com>2022-02-06 05:08:10 +0000
committerGitHub <noreply@github.com>2022-02-06 14:08:10 +0900
commit7cbb68da6c5664a4e2aba533fe1f969373c60d5c (patch)
treef8968beb750bb1b52a4744a50127a3c2288fa6b1 /ale_linters
parent0c276aac90f5a49fcf2609d348a11ee0608dd558 (diff)
downloadale-7cbb68da6c5664a4e2aba533fe1f969373c60d5c.zip
Add oelint-adv support (#4043)
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/bitbake/oelint_adv.vim47
1 files changed, 47 insertions, 0 deletions
diff --git a/ale_linters/bitbake/oelint_adv.vim b/ale_linters/bitbake/oelint_adv.vim
new file mode 100644
index 00000000..fb85a9b9
--- /dev/null
+++ b/ale_linters/bitbake/oelint_adv.vim
@@ -0,0 +1,47 @@
+" Author: offa
+" Description: oelint-adv for BitBake files
+
+call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv')
+call ale#Set('bitbake_oelint_adv_options', '')
+call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg')
+
+function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
+ let l:config_file = ale#path#FindNearestFile(a:buffer,
+ \ ale#Var(a:buffer, 'bitbake_oelint_adv_config'))
+
+ return ((!empty(l:config_file))
+ \ ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' '
+ \ : '')
+ \ . '%e --quiet '
+ \ . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) . '%s'
+endfunction
+
+function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
+ let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'type': l:match[3] is# 'error'
+ \ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
+ \ 'text': StripAnsiCodes(l:match[5]),
+ \ 'code': l:match[4]
+ \ })
+ endfor
+
+ return l:output
+endfunction
+
+function! StripAnsiCodes(line) abort
+ return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
+endfunction
+
+call ale#linter#Define('bitbake', {
+\ 'name': 'oelint_adv',
+\ 'output_stream': 'both',
+\ 'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')},
+\ 'cwd': '%s:h',
+\ 'command': function('ale_linters#bitbake#oelint_adv#Command'),
+\ 'callback': 'ale_linters#bitbake#oelint_adv#Handle',
+\ })