3 " Copyright (C) 2004 Chris Larson <kergoth@handhelds.org>
4 " This file is licensed under the MIT license, see COPYING.MIT in
5 " this source distribution for the terms.
8 " Maintainer: Chris Larson <kergoth@handhelds.org>
9 " Filenames: *.bb, *.bbclass
13 elseif exists("b:current_syntax")
19 syn match bbComment "^#.*$" display contains=bbTodo
20 syn keyword bbTodo TODO FIXME XXX contained
21 syn match bbDelimiter "[(){}=]" contained
22 syn match bbQuote /['"]/ contained
24 "syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ keepend contains=bbTodo
25 "syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ keepend contains=bbTodo
26 syn match bbContinue "\\$"
27 syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo,bbContinue
28 syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo,bbContinue
31 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
32 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef
33 " syn match bbPythonFuncDef "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag
34 " hi def link bbPythonFuncRegion Comment
35 " hi def link bbPythonFlag Type
38 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
39 " syn match bbPythonFuncDef "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag,bbFunction,bbDelimiter
40 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef,bbDelimiter
41 " hi def link bbPythonFuncRegion Comment
42 " hi def link bbPythonFlag Type
45 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
46 " syn match bbPythonFuncDef "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
47 " syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained
48 " hi def link bbPythonFuncRegion Comment
49 " hi def link bbPythonFlag Type
51 " BitBake variable metadata
52 syn match bbVarDef "^\([a-zA-Z0-9\-_]\+\)\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
53 syn match bbIdentifier "[a-zA-Z0-9\-_]\+" display contained
54 "syn keyword bbVarEq = display contained nextgroup=bbVarValue
55 syn match bbVarEq "=" contained contains=bbOperator nextgroup=bbVarValue
56 syn match bbVarValue ".*$" contained contains=bbString
59 " BitBake variable metadata flags
60 syn match bbVarFlagDef "^\([a-zA-Z0-9\-_]\+\)\(\[[a-zA-Z0-9\-_]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
61 syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq
62 "syn match bbVarFlagFlag "\[\([a-zA-Z0-9\-_]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
66 syn match bbFunction "\h\w*" display contained
69 " BitBake python metadata
70 syn include @python syntax/python.vim
71 if exists("b:current_syntax")
72 unlet b:current_syntax
75 syn keyword bbPythonFlag python contained nextgroup=bbFunction
76 syn match bbPythonFuncDef "^\(python\s\+\)\(\w\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
77 syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@python
78 "hi def link bbPythonFuncRegion Comment
81 " BitBake shell metadata
82 syn include @shell syntax/sh.vim
83 if exists("b:current_syntax")
84 unlet b:current_syntax
87 syn match bbShellFuncDef "^\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFunction,bbDelimiter nextgroup=bbShellFuncRegion
88 syn region bbShellFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@shell
89 "hi def link bbShellFuncRegion Comment
92 " BitBake 'def'd python functions
93 syn keyword bbDef def contained
95 syn match bbDefCmd "^def" contains=bbDef skipwhite nextgroup=bbDefFunc
96 syn match bbDefFunc "\w\+" contains=bbFunction contained skipwhite nextgroup=bbDefArgs
97 syn region bbDefArgs matchgroup=bbDelimiter start="(" end=")" excludenl contained skipwhite keepend contains=bbIdentifier nextgroup=bbDefRegion
98 syn region bbDefRegion matchgroup=bbDelimiter start=":$" end='^$' end='^\(\s\)\@!' contained contains=@python
102 syn keyword bbStatement include inherit addtask addhandler
104 syn match bbArrayBrackets "[\[\]]" contained
105 hi def link bbArrayBrackets Statement
107 hi def link bbContinue Special
108 hi def link bbDef Statement
109 hi def link bbPythonFlag Type
110 hi def link bbStatement Statement
111 hi def link bbString String
112 hi def link bbTodo Todo
113 hi def link bbComment Comment
114 hi def link bbOperator Operator
115 hi def link bbError Error
116 hi def link bbFunction Function
117 hi def link bbDelimiter Delimiter
118 hi def link bbIdentifier Identifier
119 hi def link bbQuote Statement
120 hi def link bbVarEq Operator
122 let b:current_syntax = "bb"