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