vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

bitbake.vim (6244B)


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