blob: 30f34474ad849bb9479c2c9d29171b81a919d4c8 [file] [log] [blame]
Bram Moolenaarb529cfb2022-07-25 15:42:07 +01001" Vim syntax file
2" Language: BitBake bb/bbclasses/inc
3" Author: Chris Larson <kergoth@handhelds.org>
4" Ricardo Salveti <rsalveti@rsalveti.net>
5" Copyright: Copyright (C) 2004 Chris Larson <kergoth@handhelds.org>
6" Copyright (C) 2008 Ricardo Salveti <rsalveti@rsalveti.net>
7"
8" This file is licensed under the MIT license, see COPYING.MIT in
9" this source distribution for the terms.
10"
11" Syntax highlighting for bb, bbclasses and inc files.
12"
13" It's an entirely new type, just has specific syntax in shell and python code
14
15if v:version < 600
16 finish
17endif
18if exists("b:current_syntax")
19 finish
20endif
21
22syn include @python syntax/python.vim
23unlet! b:current_syntax
24
25" BitBake syntax
26
27" Matching case
28syn case match
29
30" Indicates the error when nothing is matched
31syn match bbUnmatched "."
32
33" Comments
34syn cluster bbCommentGroup contains=bbTodo,@Spell
35syn keyword bbTodo COMBAK FIXME TODO XXX contained
36syn match bbComment "#.*$" contains=@bbCommentGroup
37
38" String helpers
39syn match bbQuote +['"]+ contained
40syn match bbDelimiter "[(){}=]" contained
41syn match bbArrayBrackets "[\[\]]" contained
42
43" BitBake strings
44syn match bbContinue "\\$"
45syn region bbString matchgroup=bbQuote start=+"+ skip=+\\$+ end=+"+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell
46syn region bbString matchgroup=bbQuote start=+'+ skip=+\\$+ end=+'+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell
47
48" Vars definition
49syn match bbExport "^export" nextgroup=bbIdentifier skipwhite
50syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite
51syn match bbIdentifier "[a-zA-Z0-9\-_\.\/\+]\+" display contained
52syn match bbVarDeref "${[a-zA-Z0-9\-_:\.\/\+]\+}" contained
53syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)" contained nextgroup=bbVarValue
54syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.\/\+][${}a-zA-Z0-9\-_:\.\/\+]*\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbOverrideOperator,bbVarDeref nextgroup=bbVarEq
55syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue
56syn region bbVarPyValue start=+${@+ skip=+\\$+ end=+}+ contained contains=@python
57
58" Vars metadata flags
59syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.+]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
60syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(:=\|=\|.=\|=.|+=\|=+\|?=\)\@=" contained contains=bbIdentifier nextgroup=bbVarEq
61
62" Includes and requires
63syn keyword bbInclude inherit include require contained
64syn match bbIncludeRest ".*$" contained contains=bbString,bbVarDeref
65syn match bbIncludeLine "^\(inherit\|include\|require\)\s\+" contains=bbInclude nextgroup=bbIncludeRest
66
67" Add taks and similar
68syn keyword bbStatement addtask deltask addhandler after before EXPORT_FUNCTIONS contained
69syn match bbStatementRest ".*$" skipwhite contained contains=bbStatement
70syn match bbStatementLine "^\(addtask\|deltask\|addhandler\|after\|before\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest
71
72" OE Important Functions
73syn keyword bbOEFunctions do_fetch do_unpack do_patch do_configure do_compile do_stage do_install do_package contained
74
75" Generic Functions
76syn match bbFunction "\h[0-9A-Za-z_\-\.]*" display contained contains=bbOEFunctions
77
78syn keyword bbOverrideOperator append prepend remove contained
79
80" BitBake shell metadata
81syn include @shell syntax/sh.vim
82unlet! b:current_syntax
83
84syn keyword bbShFakeRootFlag fakeroot contained
85syn match bbShFuncDef "^\(fakeroot\s*\)\?\([\.0-9A-Za-z_:${}\-\.]\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbFunction,bbOverrideOperator,bbVarDeref,bbDelimiter nextgroup=bbShFuncRegion skipwhite
86syn region bbShFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@shell
87
88" Python value inside shell functions
89syn region shDeref start=+${@+ skip=+\\$+ excludenl end=+}+ contained contains=@python
90
91" BitBake python metadata
92syn keyword bbPyFlag python contained
93syn match bbPyFuncDef "^\(fakeroot\s*\)\?\(python\)\(\s\+[0-9A-Za-z_:${}\-\.]\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbPyFlag,bbFunction,bbOverrideOperator,bbVarDeref,bbDelimiter nextgroup=bbPyFuncRegion skipwhite
94syn region bbPyFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@python
95
96" BitBake 'def'd python functions
97syn keyword bbPyDef def contained
98syn region bbPyDefRegion start='^\(def\s\+\)\([0-9A-Za-z_-]\+\)\(\s*(.*)\s*\):\s*$' end='^\(\s\|$\)\@!' contains=@python
99
100" Highlighting Definitions
101hi def link bbUnmatched Error
102hi def link bbInclude Include
103hi def link bbTodo Todo
104hi def link bbComment Comment
105hi def link bbQuote String
106hi def link bbString String
107hi def link bbDelimiter Keyword
108hi def link bbArrayBrackets Statement
109hi def link bbContinue Special
110hi def link bbExport Type
111hi def link bbExportFlag Type
112hi def link bbIdentifier Identifier
113hi def link bbVarDeref PreProc
114hi def link bbVarDef Identifier
115hi def link bbVarValue String
116hi def link bbShFakeRootFlag Type
117hi def link bbFunction Function
118hi def link bbPyFlag Type
119hi def link bbPyDef Statement
120hi def link bbStatement Statement
121hi def link bbStatementRest Identifier
122hi def link bbOEFunctions Special
123hi def link bbVarPyValue PreProc
124hi def link bbOverrideOperator Operator
125
126let b:current_syntax = "bitbake"