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