Vim syntax update: highlight the shell functions as shell.
[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 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 if exists("b:current_syntax")
58   unlet b:current_syntax
59 endif
60
61 syn keyword bbPythonFlag        python contained nextgroup=bbFunction
62 syn match bbPythonFuncDef       "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
63 syn region bbPythonFuncRegion   matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@python
64 "hi def link bbPythonFuncRegion Comment
65
66 " BitBake shell metadata
67 syn include @shell syntax/sh.vim
68 if exists("b:current_syntax")
69   unlet b:current_syntax
70 endif
71
72 syn match bbShellFuncDef        "^\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFunction,bbDelimiter nextgroup=bbShellFuncRegion
73 syn region bbShellFuncRegion    matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@shell
74 "hi def link bbShellFuncRegion  Comment
75
76
77 hi def link bbPythonFlag        Type
78 hi def link bbStatement         Statement
79 hi def link bbString            String
80 hi def link bbTodo              Todo
81 hi def link bbComment           Comment
82 hi def link bbOperator          Operator
83 hi def link bbError             Error
84 hi def link bbFunction          Function
85 hi def link bbDelimiter         Delimiter
86 hi def link bbIdentifier        Identifier
87 hi def link bbQuote             Statement
88 hi def link bbVarEq             Operator
89
90 let b:current_syntax = "bb"