blob: 4eaf6963223c5174be560654bb4ae4574e4c6f63 [file] [log] [blame]
Bram Moolenaar96f45c02019-10-26 19:53:45 +02001" Vim syntax file
2" Language: Meson
3" License: VIM License
4" Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
Bram Moolenaar3ec32172021-05-16 12:39:47 +02005" Liam Beguin <liambeguin@gmail.com>
Bram Moolenaar10e8ff92023-06-10 21:40:39 +01006" Last Change: 2023 May 27
Bram Moolenaar96f45c02019-10-26 19:53:45 +02007" 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
Bram Moolenaar3ec32172021-05-16 12:39:47 +020021if exists("b:current_syntax")
Bram Moolenaar96f45c02019-10-26 19:53:45 +020022 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
Bram Moolenaar3ec32172021-05-16 12:39:47 +020032syn keyword mesonRepeat foreach endforeach
33syn keyword mesonOperator and not or in
34syn keyword mesonStatement continue break
Bram Moolenaar96f45c02019-10-26 19:53:45 +020035
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\+\>"
Bram Moolenaar113cb512021-11-07 20:27:04 +000059syn match mesonNumber "\<0x\x\+\>"
60syn match mesonNumber "\<0o\o\+\>"
Bram Moolenaar96f45c02019-10-26 19:53:45 +020061
62" booleans
Bram Moolenaar113cb512021-11-07 20:27:04 +000063syn keyword mesonBoolean false true
Bram Moolenaar96f45c02019-10-26 19:53:45 +020064
65" Built-in functions
66syn keyword mesonBuiltin
67 \ add_global_arguments
68 \ add_global_link_arguments
69 \ add_languages
70 \ add_project_arguments
Bram Moolenaar10e8ff92023-06-10 21:40:39 +010071 \ add_project_dependencies
Bram Moolenaar96f45c02019-10-26 19:53:45 +020072 \ add_project_link_arguments
73 \ add_test_setup
74 \ alias_target
75 \ assert
76 \ benchmark
77 \ both_libraries
78 \ build_machine
79 \ build_target
80 \ configuration_data
81 \ configure_file
82 \ custom_target
83 \ declare_dependency
84 \ dependency
85 \ disabler
86 \ environment
87 \ error
88 \ executable
89 \ files
90 \ find_library
91 \ find_program
92 \ generator
93 \ get_option
94 \ get_variable
95 \ gettext
96 \ host_machine
97 \ import
98 \ include_directories
99 \ install_data
100 \ install_headers
101 \ install_man
102 \ install_subdir
Bram Moolenaar10e8ff92023-06-10 21:40:39 +0100103 \ install_symlink
Bram Moolenaar113cb512021-11-07 20:27:04 +0000104 \ install_emptydir
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200105 \ is_disabler
106 \ is_variable
107 \ jar
108 \ join_paths
109 \ library
110 \ meson
111 \ message
112 \ option
113 \ project
114 \ run_command
115 \ run_target
116 \ set_variable
117 \ shared_library
118 \ shared_module
119 \ static_library
Bram Moolenaar10e8ff92023-06-10 21:40:39 +0100120 \ structured_sources
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200121 \ subdir
122 \ subdir_done
123 \ subproject
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200124 \ summary
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200125 \ target_machine
126 \ test
Bram Moolenaar113cb512021-11-07 20:27:04 +0000127 \ unset_variable
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200128 \ vcs_tag
129 \ warning
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200130 \ range
Bram Moolenaar10e8ff92023-06-10 21:40:39 +0100131 \ debug
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200132
133if exists("meson_space_error_highlight")
134 " trailing whitespace
135 syn match mesonSpaceError display excludenl "\s\+$"
136 " mixed tabs and spaces
137 syn match mesonSpaceError display " \+\t"
138 syn match mesonSpaceError display "\t\+ "
139endif
140
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200141" The default highlight links. Can be overridden later.
142hi def link mesonStatement Statement
143hi def link mesonConditional Conditional
Bram Moolenaar113cb512021-11-07 20:27:04 +0000144hi def link mesonRepeat Repeat
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200145hi def link mesonOperator Operator
146hi def link mesonComment Comment
147hi def link mesonTodo Todo
Bram Moolenaar113cb512021-11-07 20:27:04 +0000148hi def link mesonString String
149hi def link mesonEscape Special
150hi def link mesonNumber Number
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200151hi def link mesonBuiltin Function
Bram Moolenaar113cb512021-11-07 20:27:04 +0000152hi def link mesonBoolean Boolean
Bram Moolenaar10e8ff92023-06-10 21:40:39 +0100153if exists("meson_space_error_highlight")
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200154 hi def link mesonSpaceError Error
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200155endif
156
157let b:current_syntax = "meson"
158
159let &cpo = s:cpo_save
160unlet s:cpo_save
161
162" vim:set sw=2 sts=2 ts=8 noet: