bitbake.vim 5.4 KB

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