bitbake.vim 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. if &compatible || v:version < 600
  15. finish
  16. endif
  17. if exists("b:current_syntax")
  18. finish
  19. endif
  20. syn include @python syntax/python.vim
  21. if exists("b:current_syntax")
  22. unlet b:current_syntax
  23. endif
  24. " BitBake syntax
  25. " Matching case
  26. syn case match
  27. " Indicates the error when nothing is matched
  28. syn match bbUnmatched "."
  29. " Comments
  30. syn cluster bbCommentGroup contains=bbTodo,@Spell
  31. syn keyword bbTodo COMBAK FIXME TODO XXX contained
  32. syn match bbComment "#.*$" contains=@bbCommentGroup
  33. " String helpers
  34. syn match bbQuote +['"]+ contained
  35. syn match bbDelimiter "[(){}=]" contained
  36. syn match bbArrayBrackets "[\[\]]" contained
  37. " BitBake strings
  38. syn match bbContinue "\\$"
  39. syn region bbString matchgroup=bbQuote start=+"+ skip=+\\$+ end=+"+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell
  40. syn region bbString matchgroup=bbQuote start=+'+ skip=+\\$+ end=+'+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell
  41. " Vars definition
  42. syn match bbExport "^export" nextgroup=bbIdentifier skipwhite
  43. syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite
  44. syn match bbIdentifier "[a-zA-Z0-9\-_\.\/\+]\+" display contained
  45. syn match bbVarDeref "${[a-zA-Z0-9\-_\.\/\+]\+}" contained
  46. syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)" contained nextgroup=bbVarValue
  47. syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.\/\+]\+\(_[${}a-zA-Z0-9\-_\.\/\+]\+\)\?\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq
  48. syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue
  49. syn region bbVarPyValue start=+${@+ skip=+\\$+ end=+}+ contained contains=@python
  50. " Vars metadata flags
  51. syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
  52. syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\|+=\|=+\|?=\)\@=" contained contains=bbIdentifier nextgroup=bbVarEq
  53. " Includes and requires
  54. syn keyword bbInclude inherit include require contained
  55. syn match bbIncludeRest ".*$" contained contains=bbString,bbVarDeref
  56. syn match bbIncludeLine "^\(inherit\|include\|require\)\s\+" contains=bbInclude nextgroup=bbIncludeRest
  57. " Add taks and similar
  58. syn keyword bbStatement addtask addhandler after before EXPORT_FUNCTIONS contained
  59. syn match bbStatementRest ".*$" skipwhite contained contains=bbStatement
  60. syn match bbStatementLine "^\(addtask\|addhandler\|after\|before\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest
  61. " OE Important Functions
  62. syn keyword bbOEFunctions do_fetch do_unpack do_patch do_configure do_compile do_stage do_install do_package contained
  63. " Generic Functions
  64. syn match bbFunction "\h[0-9A-Za-z_-]*" display contained contains=bbOEFunctions
  65. " BitBake shell metadata
  66. syn include @shell syntax/sh.vim
  67. if exists("b:current_syntax")
  68. unlet b:current_syntax
  69. endif
  70. syn keyword bbShFakeRootFlag fakeroot contained
  71. syn match bbShFuncDef "^\(fakeroot\s*\)\?\([0-9A-Za-z_${}-]\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbFunction,bbVarDeref,bbDelimiter nextgroup=bbShFuncRegion skipwhite
  72. syn region bbShFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@shell
  73. " Python value inside shell functions
  74. syn region shDeref start=+${@+ skip=+\\$+ excludenl end=+}+ contained contains=@python
  75. " BitBake python metadata
  76. syn keyword bbPyFlag python contained
  77. syn match bbPyFuncDef "^\(python\s\+\)\([0-9A-Za-z_${}-]\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPyFlag,bbFunction,bbVarDeref,bbDelimiter nextgroup=bbPyFuncRegion skipwhite
  78. syn region bbPyFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" contained contains=@python
  79. " BitBake 'def'd python functions
  80. syn keyword bbPyDef def contained
  81. syn region bbPyDefRegion start='^\(def\s\+\)\([0-9A-Za-z_-]\+\)\(\s*(.*)\s*\):\s*$' end='^\(\s\|$\)\@!' contains=@python
  82. " Highlighting Definitions
  83. hi def link bbUnmatched Error
  84. hi def link bbInclude Include
  85. hi def link bbTodo Todo
  86. hi def link bbComment Comment
  87. hi def link bbQuote String
  88. hi def link bbString String
  89. hi def link bbDelimiter Keyword
  90. hi def link bbArrayBrackets Statement
  91. hi def link bbContinue Special
  92. hi def link bbExport Type
  93. hi def link bbExportFlag Type
  94. hi def link bbIdentifier Identifier
  95. hi def link bbVarDeref PreProc
  96. hi def link bbVarDef Identifier
  97. hi def link bbVarValue String
  98. hi def link bbShFakeRootFlag Type
  99. hi def link bbFunction Function
  100. hi def link bbPyFlag Type
  101. hi def link bbPyDef Statement
  102. hi def link bbStatement Statement
  103. hi def link bbStatementRest Identifier
  104. hi def link bbOEFunctions Special
  105. hi def link bbVarPyValue PreProc
  106. let b:current_syntax = "bb"