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