Skip to content

Commit bce573b

Browse files
authored
Add syntax highlighting for meson build system (zyedidia#3236)
* Add syntax highlighting for meson build system It is basically a port of upstream syntax highlighting for vim, but a bit less noisy (e.g numbers are not colored). * meson.yaml: fix meson_options.txt detection * meson.yaml: remove empty rules * meson.yaml: add highlighting for operators and brackets * meson.yaml: rearrange the keywords to be in alphabetical order * meson.yaml: add highlighting for numbers
1 parent 774a6d8 commit bce573b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

runtime/syntax/meson.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
filetype: meson
2+
3+
detect:
4+
filename: "(meson\\.build|meson_options\\.txt|meson\\.options)"
5+
6+
rules:
7+
8+
# refer to https://mesonbuild.com/Syntax.html
9+
10+
- statement: "\\b(elif|else|if|endif)\\b"
11+
- statement: "\\b(foreach|endforeach)\\b"
12+
- statement: "\\b(continue|break)\\b"
13+
- statement: "\\b(and|not|or|in)\\b"
14+
15+
- symbol.operator: "[<>?:+*/-]|[+!<>=]?="
16+
- symbol.brackets: "[(){}\\[\\]]"
17+
18+
- constant.number: "\\b(0|[1-9][0-9]*)\\b" # decimal
19+
- constant.number: "\\b(0b[01]+)\\b" # bin
20+
- constant.number: "\\b(0o[0-7]+)\\b" # oct
21+
- constant.number: "\\b(0x[0-9a-fA-F]+)\\b" # hex
22+
23+
# meson builtins
24+
- identifier: "\\b(add_global_arguments|add_global_link_arguments|add_languages|add_project_arguments|add_project_dependencies)\\b"
25+
- identifier: "\\b(add_project_link_arguments|add_test_setup|alias_target|assert|benchmark|both_libraries|build_machine|build_target|configuration_data)\\b"
26+
- identifier: "\\b(configure_file|custom_target|debug|declare_dependency|dependency|disabler|environment|error|executable|files)\\b"
27+
- identifier: "\\b(find_program|generator|get_option|get_variable|host_machine|import|include_directories|install_data|install_emptydir)\\b"
28+
- identifier: "\\b(install_headers|install_man|install_subdir|install_symlink|is_disabler|is_variable|jar|join_paths|library|meson)\\b"
29+
- identifier: "\\b(message|option|project|range|run_command|run_target|set_variable|shared_library|shared_module|static_library)\\b"
30+
- identifier: "\\b(structured_sources|subdir|subdir_done|subproject|summary|target_machine|test|unset_variable|vcs_tag|warning)\\b"
31+
32+
- constant.bool: "\\b(true|false)\\b"
33+
34+
- comment:
35+
start: "#"
36+
end: "$"
37+
38+
# multiline strings do not support escape sequences
39+
- constant.string:
40+
start: "'''"
41+
end: "'''"
42+
43+
- constant.string:
44+
start: "'"
45+
end: "'"
46+
skip: "\\\\."
47+
rules:
48+
- constant.specialChar: "\\\\[abfnrtv\\\\']"
49+
- constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|N\\{[^\\}]+\\})"

0 commit comments

Comments
 (0)