blob: 7e6b565f197969f9ad99a166a5b44413e63296d1 [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 Moolenaar96f45c02019-10-26 19:53:45 +02006" Last Change: 2019 Oct 18
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
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\+\>"
59
60" booleans
61syn keyword mesonConstant false true
62
63" Built-in functions
64syn keyword mesonBuiltin
65 \ add_global_arguments
66 \ add_global_link_arguments
67 \ add_languages
68 \ add_project_arguments
69 \ add_project_link_arguments
70 \ add_test_setup
71 \ alias_target
72 \ assert
73 \ benchmark
74 \ both_libraries
75 \ build_machine
76 \ build_target
77 \ configuration_data
78 \ configure_file
79 \ custom_target
80 \ declare_dependency
81 \ dependency
82 \ disabler
83 \ environment
84 \ error
85 \ executable
86 \ files
87 \ find_library
88 \ find_program
89 \ generator
90 \ get_option
91 \ get_variable
92 \ gettext
93 \ host_machine
94 \ import
95 \ include_directories
96 \ install_data
97 \ install_headers
98 \ install_man
99 \ install_subdir
100 \ is_disabler
101 \ is_variable
102 \ jar
103 \ join_paths
104 \ library
105 \ meson
106 \ message
107 \ option
108 \ project
109 \ run_command
110 \ run_target
111 \ set_variable
112 \ shared_library
113 \ shared_module
114 \ static_library
115 \ subdir
116 \ subdir_done
117 \ subproject
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200118 \ summary
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200119 \ target_machine
120 \ test
121 \ vcs_tag
122 \ warning
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200123 \ range
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200124
125if exists("meson_space_error_highlight")
126 " trailing whitespace
127 syn match mesonSpaceError display excludenl "\s\+$"
128 " mixed tabs and spaces
129 syn match mesonSpaceError display " \+\t"
130 syn match mesonSpaceError display "\t\+ "
131endif
132
Bram Moolenaar3ec32172021-05-16 12:39:47 +0200133" The default highlight links. Can be overridden later.
134hi def link mesonStatement Statement
135hi def link mesonConditional Conditional
136hi def link mesonRepeat Repeat
137hi def link mesonOperator Operator
138hi def link mesonComment Comment
139hi def link mesonTodo Todo
140hi def link mesonString String
141hi def link mesonEscape Special
142hi def link mesonNumber Number
143hi def link mesonBuiltin Function
144hi def link mesonConstant Number
145if exists("meson_space_error_higlight")
146 hi def link mesonSpaceError Error
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200147endif
148
149let b:current_syntax = "meson"
150
151let &cpo = s:cpo_save
152unlet s:cpo_save
153
154" vim:set sw=2 sts=2 ts=8 noet: