meson.vim 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. " Vim syntax file
  2. " Language: Meson
  3. " License: VIM License
  4. " Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
  5. " Liam Beguin <liambeguin@gmail.com>
  6. " Last Change: 2021 Aug 16
  7. " Credits: Zvezdan Petkovic <zpetkovic@acm.org>
  8. " Neil Schemenauer <nas@meson.ca>
  9. " Dmitry Vasiliev
  10. "
  11. " This version is copied and edited from python.vim
  12. " It's very basic, and doesn't do many things I'd like it to
  13. " For instance, it should show errors for syntax that is valid in
  14. " Python but not in Meson.
  15. "
  16. " Optional highlighting can be controlled using these variables.
  17. "
  18. " let meson_space_error_highlight = 1
  19. "
  20. if exists("b:current_syntax")
  21. finish
  22. endif
  23. " We need nocompatible mode in order to continue lines with backslashes.
  24. " Original setting will be restored.
  25. let s:cpo_save = &cpo
  26. set cpo&vim
  27. " http://mesonbuild.com/Syntax.html
  28. syn keyword mesonConditional elif else if endif
  29. syn keyword mesonRepeat foreach endforeach
  30. syn keyword mesonOperator and not or in
  31. syn keyword mesonStatement continue break
  32. syn match mesonComment "#.*$" contains=mesonTodo,@Spell
  33. syn keyword mesonTodo FIXME NOTE NOTES TODO XXX contained
  34. " Strings can either be single quoted or triple counted across multiple lines,
  35. " but always with a '
  36. syn region mesonString
  37. \ start="\z('\)" end="\z1" skip="\\\\\|\\\z1"
  38. \ contains=mesonEscape,@Spell
  39. syn region mesonString
  40. \ start="\z('''\)" end="\z1" keepend
  41. \ contains=mesonEscape,mesonSpaceError,@Spell
  42. syn match mesonEscape "\\[abfnrtv'\\]" contained
  43. syn match mesonEscape "\\\o\{1,3}" contained
  44. syn match mesonEscape "\\x\x\{2}" contained
  45. syn match mesonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained
  46. " Meson allows case-insensitive Unicode IDs: http://www.unicode.org/charts/
  47. syn match mesonEscape "\\N{\a\+\%(\s\a\+\)*}" contained
  48. syn match mesonEscape "\\$"
  49. " Meson only supports integer numbers
  50. " http://mesonbuild.com/Syntax.html#numbers
  51. syn match mesonNumber "\<\d\+\>"
  52. syn match mesonNumber "\<0x\x\+\>"
  53. syn match mesonNumber "\<0o\o\+\>"
  54. " booleans
  55. syn keyword mesonBoolean false true
  56. " Built-in functions
  57. syn keyword mesonBuiltin
  58. \ add_global_arguments
  59. \ add_global_link_arguments
  60. \ add_languages
  61. \ add_project_arguments
  62. \ add_project_link_arguments
  63. \ add_test_setup
  64. \ alias_target
  65. \ assert
  66. \ benchmark
  67. \ both_libraries
  68. \ build_machine
  69. \ build_target
  70. \ configuration_data
  71. \ configure_file
  72. \ custom_target
  73. \ declare_dependency
  74. \ dependency
  75. \ disabler
  76. \ environment
  77. \ error
  78. \ executable
  79. \ files
  80. \ find_library
  81. \ find_program
  82. \ generator
  83. \ get_option
  84. \ get_variable
  85. \ gettext
  86. \ host_machine
  87. \ import
  88. \ include_directories
  89. \ install_data
  90. \ install_headers
  91. \ install_man
  92. \ install_subdir
  93. \ install_emptydir
  94. \ is_disabler
  95. \ is_variable
  96. \ jar
  97. \ join_paths
  98. \ library
  99. \ meson
  100. \ message
  101. \ option
  102. \ project
  103. \ run_command
  104. \ run_target
  105. \ set_variable
  106. \ shared_library
  107. \ shared_module
  108. \ static_library
  109. \ subdir
  110. \ subdir_done
  111. \ subproject
  112. \ summary
  113. \ target_machine
  114. \ test
  115. \ unset_variable
  116. \ vcs_tag
  117. \ warning
  118. \ range
  119. if exists("meson_space_error_highlight")
  120. " trailing whitespace
  121. syn match mesonSpaceError display excludenl "\s\+$"
  122. " mixed tabs and spaces
  123. syn match mesonSpaceError display " \+\t"
  124. syn match mesonSpaceError display "\t\+ "
  125. endif
  126. " The default highlight links. Can be overridden later.
  127. hi def link mesonStatement Statement
  128. hi def link mesonConditional Conditional
  129. hi def link mesonRepeat Repeat
  130. hi def link mesonOperator Operator
  131. hi def link mesonComment Comment
  132. hi def link mesonTodo Todo
  133. hi def link mesonString String
  134. hi def link mesonEscape Special
  135. hi def link mesonNumber Number
  136. hi def link mesonBuiltin Function
  137. hi def link mesonBoolean Boolean
  138. if exists("meson_space_error_higlight")
  139. hi def link mesonSpaceError Error
  140. endif
  141. let b:current_syntax = "meson"
  142. let &cpo = s:cpo_save
  143. unlet s:cpo_save
  144. " vim:set sw=2 sts=2 ts=8 noet: