diff options
Diffstat (limited to 'bitbake/contrib/vim/syntax/bitbake.vim')
| -rw-r--r-- | bitbake/contrib/vim/syntax/bitbake.vim | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/bitbake/contrib/vim/syntax/bitbake.vim b/bitbake/contrib/vim/syntax/bitbake.vim new file mode 100644 index 0000000000..5d2bc633e1 --- /dev/null +++ b/bitbake/contrib/vim/syntax/bitbake.vim | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | " Vim syntax file | ||
| 2 | " | ||
| 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. | ||
| 6 | " | ||
| 7 | " Language: BitBake | ||
| 8 | " Maintainer: Chris Larson <kergoth@handhelds.org> | ||
| 9 | " Filenames: *.bb, *.bbclass | ||
| 10 | |||
| 11 | if version < 600 | ||
| 12 | syntax clear | ||
| 13 | elseif exists("b:current_syntax") | ||
| 14 | finish | ||
| 15 | endif | ||
| 16 | |||
| 17 | syn case match | ||
| 18 | |||
| 19 | |||
| 20 | " Catch incorrect syntax (only matches if nothing else does) | ||
| 21 | " | ||
| 22 | syn match bbUnmatched "." | ||
| 23 | |||
| 24 | |||
| 25 | " Other | ||
| 26 | |||
| 27 | syn match bbComment "^#.*$" display contains=bbTodo | ||
| 28 | syn keyword bbTodo TODO FIXME XXX contained | ||
| 29 | syn match bbDelimiter "[(){}=]" contained | ||
| 30 | syn match bbQuote /['"]/ contained | ||
| 31 | syn match bbArrayBrackets "[\[\]]" contained | ||
| 32 | |||
| 33 | |||
| 34 | " BitBake strings | ||
| 35 | |||
| 36 | syn match bbContinue "\\$" | ||
| 37 | syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo,bbContinue,bbVarDeref | ||
| 38 | syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo,bbContinue,bbVarDeref | ||
| 39 | |||
| 40 | |||
| 41 | " BitBake variable metadata | ||
| 42 | |||
| 43 | syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite | ||
| 44 | syn match bbVarDeref "${[a-zA-Z0-9\-_\.]\+}" contained | ||
| 45 | syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.]\+\(_[${}a-zA-Z0-9\-_\.]\+\)\?\)\s*\(\(:=\)\|\(+=\)\|\(=+\)\|\(?=\)\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq | ||
| 46 | |||
| 47 | syn match bbIdentifier "[a-zA-Z0-9\-_\.]\+" display contained | ||
| 48 | "syn keyword bbVarEq = display contained nextgroup=bbVarValue | ||
| 49 | syn match bbVarEq "\(:=\)\|\(+=\)\|\(=+\)\|\(?=\)\|=" contained nextgroup=bbVarValue | ||
| 50 | syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref | ||
| 51 | |||
| 52 | |||
| 53 | " BitBake variable metadata flags | ||
| 54 | syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag | ||
| 55 | syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq | ||
| 56 | "syn match bbVarFlagFlag "\[\([a-zA-Z0-9\-_\.]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq | ||
| 57 | |||
| 58 | |||
| 59 | " Functions! | ||
| 60 | syn match bbFunction "\h\w*" display contained | ||
| 61 | |||
| 62 | |||
| 63 | " BitBake python metadata | ||
| 64 | syn include @python syntax/python.vim | ||
| 65 | if exists("b:current_syntax") | ||
| 66 | unlet b:current_syntax | ||
| 67 | endif | ||
| 68 | |||
| 69 | syn keyword bbPythonFlag python contained nextgroup=bbFunction | ||
| 70 | syn match bbPythonFuncDef "^\(python\s\+\)\(\w\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion skipwhite | ||
| 71 | syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@python | ||
| 72 | "hi def link bbPythonFuncRegion Comment | ||
| 73 | |||
| 74 | |||
| 75 | " BitBake shell metadata | ||
| 76 | syn include @shell syntax/sh.vim | ||
| 77 | if exists("b:current_syntax") | ||
| 78 | unlet b:current_syntax | ||
| 79 | endif | ||
| 80 | |||
| 81 | syn keyword bbFakerootFlag fakeroot contained nextgroup=bbFunction | ||
| 82 | syn match bbShellFuncDef "^\(fakeroot\s*\)\?\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFakerootFlag,bbFunction,bbDelimiter nextgroup=bbShellFuncRegion skipwhite | ||
| 83 | syn region bbShellFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" 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 | syn region bbDefRegion start='^def\s\+\w\+\s*([^)]*)\s*:\s*$' end='^\(\s\|$\)\@!' contains=@python | ||
| 90 | |||
| 91 | |||
| 92 | " BitBake statements | ||
| 93 | syn keyword bbStatement include inherit addtask addhandler EXPORT_FUNCTIONS display contained | ||
| 94 | syn match bbStatementLine "^\(include\|inherit\|addtask\|addhandler\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest | ||
| 95 | syn match bbStatementRest ".*$" contained contains=bbString,bbVarDeref | ||
| 96 | |||
| 97 | " Highlight | ||
| 98 | " | ||
| 99 | hi def link bbArrayBrackets Statement | ||
| 100 | hi def link bbUnmatched Error | ||
| 101 | hi def link bbVarDeref String | ||
| 102 | hi def link bbContinue Special | ||
| 103 | hi def link bbDef Statement | ||
| 104 | hi def link bbPythonFlag Type | ||
| 105 | hi def link bbExportFlag Type | ||
| 106 | hi def link bbFakerootFlag Type | ||
| 107 | hi def link bbStatement Statement | ||
| 108 | hi def link bbString String | ||
| 109 | hi def link bbTodo Todo | ||
| 110 | hi def link bbComment Comment | ||
| 111 | hi def link bbOperator Operator | ||
| 112 | hi def link bbError Error | ||
| 113 | hi def link bbFunction Function | ||
| 114 | hi def link bbDelimiter Delimiter | ||
| 115 | hi def link bbIdentifier Identifier | ||
| 116 | hi def link bbVarEq Operator | ||
| 117 | hi def link bbQuote String | ||
| 118 | hi def link bbVarValue String | ||
| 119 | |||
| 120 | let b:current_syntax = "bb" | ||
