Start adding vim syntax highlighting.
[vuplus_bitbake] / contrib / vim / syntax / bb.vim
1 " Vim syntax file
2 "
3 " Language:     BitBake
4 " Maintainer:   Chris Larson <kergoth@handhelds.org>
5 " Filenames:    *.bb, *.bbclass
6
7 if version < 600
8   syntax clear
9 elseif exists("b:current_syntax")
10   finish
11 endif
12
13 syn case match
14
15 syn match bbComment             "^#.*$" display contains=bbTodo
16 syn keyword bbTodo              TODO FIXME XXX contained
17 syn match bbDelimiter           "[(){}=]" contained
18 syn match bbQuote               /['"]/ contained
19
20 "syn region bbString            matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ keepend contains=bbTodo
21 "syn region bbString            matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ keepend contains=bbTodo
22 syn region bbString             matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo
23 syn region bbString             matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo
24
25 syn match bbFunction    "\h\w*" display contained
26
27 " First attempt:
28 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
29 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef
30 " syn match bbPythonFuncDef     "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag
31 " hi def link bbPythonFuncRegion        Comment
32 " hi def link bbPythonFlag      Type
33
34 " Second attempt:
35 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
36 " syn match bbPythonFuncDef     "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag,bbFunction,bbDelimiter
37 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef,bbDelimiter
38 " hi def link bbPythonFuncRegion        Comment
39 " hi def link bbPythonFlag      Type
40
41 " Third attempt:
42 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
43 " syn match bbPythonFuncDef     "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
44 " syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained
45 " hi def link bbPythonFuncRegion        Comment
46 " hi def link bbPythonFlag      Type
47
48 " BitBake variable metadata
49 syn match bbVarDef              "^\([a-zA-Z0-9\-_]\+\)\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
50 syn match bbIdentifier          "[a-zA-Z0-9\-_]\+" display contained
51 "syn keyword bbVarEq    = display contained nextgroup=bbVarValue
52 syn match bbVarEq               "=" contained contains=bbOperator nextgroup=bbVarValue
53 syn match bbVarValue            ".*$" contained contains=bbString
54
55 " BitBake python metadata
56 syn include @python syntax/python.vim
57
58 syn keyword bbPythonFlag        python contained nextgroup=bbFunction
59 syn match bbPythonFuncDef       "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
60 syn region bbPythonFuncRegion   matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@python
61 "hi def link bbPythonFuncRegion Comment
62 hi def link bbPythonFlag        Type
63
64 hi def link bbStatement         Statement
65 hi def link bbString            String
66 hi def link bbTodo              Todo
67 hi def link bbComment           Comment
68 hi def link bbOperator          Operator
69 hi def link bbError             Error
70 hi def link bbFunction          Function
71 hi def link bbDelimiter         Delimiter
72 hi def link bbIdentifier        Identifier
73 hi def link bbQuote             Statement
74 hi def link bbVarEq             Operator