blob: 8f39b8f95115716f7dd3864c4db0d150b5007b07 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001" 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
Andrew Geissler475cb722020-07-10 16:00:51 -050015if &compatible || v:version < 600 || exists("b:loaded_bitbake_plugin")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016 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
Patrick Williams213cb262021-08-07 19:21:33 -050054syn match bbVarDeref "${[a-zA-Z0-9\-_:\.\/\+]\+}" contained
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)" contained nextgroup=bbVarValue
Patrick Williams213cb262021-08-07 19:21:33 -050056syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.\/\+][${}a-zA-Z0-9\-_:\.\/\+]*\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbOverrideOperator,bbVarDeref nextgroup=bbVarEq
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue
58syn region bbVarPyValue start=+${@+ skip=+\\$+ end=+}+ contained contains=@python
59
60" Vars metadata flags
Andrew Geissler475cb722020-07-10 16:00:51 -050061syn 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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
64" Includes and requires
65syn keyword bbInclude inherit include require contained
Patrick Williams169d7bc2024-01-05 11:33:25 -060066syn match bbIncludeRest ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067syn match bbIncludeLine "^\(inherit\|include\|require\)\s\+" contains=bbInclude nextgroup=bbIncludeRest
68
69" Add taks and similar
Andrew Geissler475cb722020-07-10 16:00:51 -050070syn keyword bbStatement addtask deltask addhandler after before EXPORT_FUNCTIONS contained
Patrick Williams169d7bc2024-01-05 11:33:25 -060071syn match bbStatementRest /[^\\]*$/ skipwhite contained contains=bbStatement,bbVarDeref,bbVarPyValue
72syn region bbStatementRestCont start=/.*\\$/ end=/^[^\\]*$/ contained contains=bbStatement,bbVarDeref,bbVarPyValue,bbContinue keepend
73syn match bbStatementLine "^\(addtask\|deltask\|addhandler\|after\|before\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest,bbStatementRestCont
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074
75" OE Important Functions
76syn keyword bbOEFunctions do_fetch do_unpack do_patch do_configure do_compile do_stage do_install do_package contained
77
78" Generic Functions
Andrew Geissler475cb722020-07-10 16:00:51 -050079syn match bbFunction "\h[0-9A-Za-z_\-\.]*" display contained contains=bbOEFunctions
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050081syn keyword bbOverrideOperator append prepend remove contained
Patrick Williams213cb262021-08-07 19:21:33 -050082
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083" BitBake shell metadata
84syn include @shell syntax/sh.vim
85if exists("b:current_syntax")
86 unlet b:current_syntax
87endif
88syn keyword bbShFakeRootFlag fakeroot contained
Patrick Williams213cb262021-08-07 19:21:33 -050089syn match bbShFuncDef "^\(fakeroot\s*\)\?\([\.0-9A-Za-z_:${}\-\.]\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbFunction,bbOverrideOperator,bbVarDeref,bbDelimiter nextgroup=bbShFuncRegion skipwhite
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090syn region bbShFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@shell
91
92" Python value inside shell functions
93syn region shDeref start=+${@+ skip=+\\$+ excludenl end=+}+ contained contains=@python
94
95" BitBake python metadata
96syn keyword bbPyFlag python contained
Patrick Williams213cb262021-08-07 19:21:33 -050097syn match bbPyFuncDef "^\(fakeroot\s*\)\?\(python\)\(\s\+[0-9A-Za-z_:${}\-\.]\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbPyFlag,bbFunction,bbOverrideOperator,bbVarDeref,bbDelimiter nextgroup=bbPyFuncRegion skipwhite
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098syn region bbPyFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@python
99
100" BitBake 'def'd python functions
101syn keyword bbPyDef def contained
102syn region bbPyDefRegion start='^\(def\s\+\)\([0-9A-Za-z_-]\+\)\(\s*(.*)\s*\):\s*$' end='^\(\s\|$\)\@!' contains=@python
103
104" Highlighting Definitions
105hi def link bbUnmatched Error
106hi def link bbInclude Include
107hi def link bbTodo Todo
108hi def link bbComment Comment
109hi def link bbQuote String
110hi def link bbString String
111hi def link bbDelimiter Keyword
112hi def link bbArrayBrackets Statement
113hi def link bbContinue Special
114hi def link bbExport Type
115hi def link bbExportFlag Type
116hi def link bbIdentifier Identifier
117hi def link bbVarDeref PreProc
118hi def link bbVarDef Identifier
119hi def link bbVarValue String
120hi def link bbShFakeRootFlag Type
121hi def link bbFunction Function
122hi def link bbPyFlag Type
123hi def link bbPyDef Statement
124hi def link bbStatement Statement
125hi def link bbStatementRest Identifier
Patrick Williams169d7bc2024-01-05 11:33:25 -0600126hi def link bbStatementRestCont Identifier
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127hi def link bbOEFunctions Special
128hi def link bbVarPyValue PreProc
Patrick Williams213cb262021-08-07 19:21:33 -0500129hi def link bbOverrideOperator Operator
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130
131let b:current_syntax = "bb"