Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-syntax:master commit in: /, syntax_checkers/ebuild/
Date: Mon, 21 Feb 2022 18:15:22
Message-Id: 1645467300.7e8691060c2a5a1aae36334cd6bc0c2c597e5521.mgorny@gentoo
1 commit: 7e8691060c2a5a1aae36334cd6bc0c2c597e5521
2 Author: Anna “CyberTailor” <cyber <AT> sysrq <DOT> in>
3 AuthorDate: Fri Feb 18 18:07:26 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 21 18:15:00 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-syntax.git/commit/?id=7e869106
7
8 pkgcheck: add new Syntastic checker
9
10 Signed-off-by: Anna Vyalkova <cyber+gentoo <AT> sysrq.in>
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 Makefile | 1 +
14 syntax_checkers/ebuild/pkgcheck.vim | 52 +++++++++++++++++++++++++++++++++++++
15 2 files changed, 53 insertions(+)
16
17 diff --git a/Makefile b/Makefile
18 index 8e170fd..87daee1 100644
19 --- a/Makefile
20 +++ b/Makefile
21 @@ -13,6 +13,7 @@ files = $(wildcard \
22 indent/* \
23 plugin/* \
24 syntax/* \
25 + syntax_checkers/* \
26 )
27
28 scripts: ${files}
29
30 diff --git a/syntax_checkers/ebuild/pkgcheck.vim b/syntax_checkers/ebuild/pkgcheck.vim
31 new file mode 100644
32 index 0000000..f8c1b4e
33 --- /dev/null
34 +++ b/syntax_checkers/ebuild/pkgcheck.vim
35 @@ -0,0 +1,52 @@
36 +" Syntax checking plugin for syntastic
37 +" Language: Gentoo Ebuilds/Eclasses
38 +" Author: Anna Vyalkova <cyber+gentoo@×××××.in>
39 +" Copyright: Copyright (c) 2022 Anna Vyalkova
40 +" Licence: You may redistribute this under the same terms as Vim itself
41 +"
42 +" Syntax checker for ebuilds and eclasses powered by pkgcheck.
43 +" Requires vim 7.0.175 or later.
44 +"
45 +
46 +if exists('g:loaded_syntastic_ebuild_pkgcheck_checker')
47 + finish
48 +endif
49 +let g:loaded_syntastic_ebuild_pkgcheck_checker = 1
50 +
51 +let s:save_cpo = &cpo
52 +set cpo&vim
53 +
54 +function! SyntaxCheckers_ebuild_pkgcheck_GetLocList() dict
55 + let makeprg = self.makeprgBuild({
56 + \ 'args_before': 'scan',
57 + \ 'args': '-R FormatReporter',
58 + \ 'args_after': '--format "{lineno}:{level}:{name}: {desc}"' })
59 +
60 + let errorformat =
61 + \ '%l:%tnfo:%m,' . ':%tnfo:%m,' .
62 + \ '%W%l:style:%m,' . '%W:style:%m,' .
63 + \ '%l:%tarning:%m,' . ':%tarning:%m,' .
64 + \ '%l:%trror:%m,' . ':%trror:%m'
65 +
66 + let loclist = SyntasticMake({
67 + \ 'makeprg': makeprg,
68 + \ 'errorformat': errorformat,
69 + \ 'defaults': {'bufnr': bufnr(''), 'type': 'E', 'text': 'Syntax error'},
70 + \ 'returns': [0, 1] })
71 +
72 + for e in loclist
73 + if e['valid'] && e['lnum'] == 0
74 + let e['lnum'] = str2nr(matchstr(e['text'], '\m\<lines\? \zs\d\+\ze'))
75 + endif
76 + endfor
77 +
78 + return loclist
79 +endfunction
80 +
81 +call g:SyntasticRegistry.CreateAndRegisterChecker({
82 + \ 'filetype': 'ebuild',
83 + \ 'name': 'pkgcheck',
84 + \ 'exec': 'pkgcheck'})
85 +
86 +let &cpo = s:save_cpo
87 +unlet s:save_cpo