Vim syntax update: highlight the ending ':' on a 'def' line.
[bitbake.git] / 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 " First attempt:
26 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
27 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef
28 " syn match bbPythonFuncDef     "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag
29 " hi def link bbPythonFuncRegion        Comment
30 " hi def link bbPythonFlag      Type
31
32 " Second attempt:
33 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
34 " syn match bbPythonFuncDef     "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag,bbFunction,bbDelimiter
35 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef,bbDelimiter
36 " hi def link bbPythonFuncRegion        Comment
37 " hi def link bbPythonFlag      Type
38
39 " Third attempt:
40 " syn keyword bbPythonFlag      python contained nextgroup=bbFunction
41 " syn match bbPythonFuncDef     "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
42 " syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained
43 " hi def link bbPythonFuncRegion        Comment
44 " hi def link bbPythonFlag      Type
45
46 " BitBake variable metadata
47 syn match bbVarDef              "^\([a-zA-Z0-9\-_]\+\)\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
48 syn match bbIdentifier          "[a-zA-Z0-9\-_]\+" display contained
49 "syn keyword bbVarEq    = display contained nextgroup=bbVarValue
50 syn match bbVarEq               "=" contained contains=bbOperator nextgroup=bbVarValue
51 syn match bbVarValue            ".*$" contained contains=bbString
52
53
54 " BitBake variable metadata flags
55 syn match bbVarFlagDef          "^\([a-zA-Z0-9\-_]\+\)\(\[[a-zA-Z0-9\-_]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
56 syn region bbVarFlagFlag        matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq
57 "syn match bbVarFlagFlag                "\[\([a-zA-Z0-9\-_]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
58
59
60 " Functions!
61 syn match bbFunction    "\h\w*" display contained
62
63
64 " BitBake python metadata
65 syn include @python syntax/python.vim
66 if exists("b:current_syntax")
67   unlet b:current_syntax
68 endif
69
70 syn keyword bbPythonFlag        python contained nextgroup=bbFunction
71 syn match bbPythonFuncDef       "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
72 syn region bbPythonFuncRegion   matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@python
73 "hi def link bbPythonFuncRegion Comment
74
75
76 " BitBake shell metadata
77 syn include @shell syntax/sh.vim
78 if exists("b:current_syntax")
79   unlet b:current_syntax
80 endif
81
82 syn match bbShellFuncDef        "^\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFunction,bbDelimiter nextgroup=bbShellFuncRegion
83 syn region bbShellFuncRegion    matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@shell
84 "hi def link bbShellFuncRegion  Comment
85
86
87 " BitBake 'def'd python functions
88 syn keyword bbDef       def     contained
89
90 syn match bbDefCmd              "^def" contains=bbDef skipwhite nextgroup=bbDefFunc
91 syn match bbDefFunc             "\w\+" contains=bbFunction contained skipwhite nextgroup=bbDefArgs
92 syn region bbDefArgs            matchgroup=bbDelimiter start="(" end=")" excludenl contained skipwhite keepend contains=bbIdentifier nextgroup=bbDefRegion
93 syn region bbDefRegion          matchgroup=bbDelimiter start=":$" end='^$' end='^\(\s\)\@!' contained contains=@python
94
95
96 " BitBake statements
97 syn keyword bbStatement         include inherit addtask addhandler
98
99 syn match bbArrayBrackets       "[\[\]]" contained
100 hi def link bbArrayBrackets     Statement
101
102 hi def link bbDef               Statement
103 hi def link bbPythonFlag        Type
104 hi def link bbStatement         Statement
105 hi def link bbString            String
106 hi def link bbTodo              Todo
107 hi def link bbComment           Comment
108 hi def link bbOperator          Operator
109 hi def link bbError             Error
110 hi def link bbFunction          Function
111 hi def link bbDelimiter         Delimiter
112 hi def link bbIdentifier        Identifier
113 hi def link bbQuote             Statement
114 hi def link bbVarEq             Operator
115
116 let b:current_syntax = "bb"