| 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: 2023 Aug 27 |
| 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 |
|
| 21 |
if exists("b:current_syntax") |
| 22 |
finish |
| 23 |
endif |
| 24 |
|
| 25 |
" We need nocompatible mode in order to continue lines with backslashes. |
| 26 |
" Original setting will be restored. |
| 27 |
let s:cpo_save = &cpo |
| 28 |
set cpo&vim |
| 29 |
|
| 30 |
" http://mesonbuild.com/Syntax.html |
| 31 |
syn keyword mesonConditional elif else if endif |
| 32 |
syn keyword mesonRepeat foreach endforeach |
| 33 |
syn keyword mesonOperator and not or in |
| 34 |
syn keyword mesonStatement continue break |
| 35 |
|
| 36 |
syn match mesonComment "#.*$" contains=mesonTodo,@Spell |
| 37 |
syn 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 ' |
| 41 |
syn region mesonString |
| 42 |
\ start="\z('\)" end="\z1" skip="\\\\\|\\\z1" |
| 43 |
\ contains=mesonEscape,@Spell |
| 44 |
syn region mesonString |
| 45 |
\ start="\z('''\)" end="\z1" keepend |
| 46 |
\ contains=mesonEscape,mesonSpaceError,@Spell |
| 47 |
|
| 48 |
syn match mesonEscape "\\[abfnrtv'\\]" contained |
| 49 |
syn match mesonEscape "\\\o\{1,3}" contained |
| 50 |
syn match mesonEscape "\\x\x\{2}" contained |
| 51 |
syn match mesonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained |
| 52 |
" Meson allows case-insensitive Unicode IDs: http://www.unicode.org/charts/ |
| 53 |
syn match mesonEscape "\\N{\a\+\%(\s\a\+\)*}" contained |
| 54 |
syn match mesonEscape "\\$" |
| 55 |
|
| 56 |
" Meson only supports integer numbers |
| 57 |
" http://mesonbuild.com/Syntax.html#numbers |
| 58 |
syn match mesonNumber "\<\d\+\>" |
| 59 |
syn match mesonNumber "\<0x\x\+\>" |
| 60 |
syn match mesonNumber "\<0o\o\+\>" |
| 61 |
|
| 62 |
" booleans |
| 63 |
syn keyword mesonBoolean false true |
| 64 |
|
| 65 |
" Built-in functions |
| 66 |
syn keyword mesonBuiltin |
| 67 |
\ build_machine |
| 68 |
\ host_machine |
| 69 |
\ meson |
| 70 |
\ option |
| 71 |
\ target_machine |
| 72 |
\ {{builtin_funcs}} |
| 73 |
|
| 74 |
if exists("meson_space_error_highlight") |
| 75 |
" trailing whitespace |
| 76 |
syn match mesonSpaceError display excludenl "\s\+$" |
| 77 |
" mixed tabs and spaces |
| 78 |
syn match mesonSpaceError display " \+\t" |
| 79 |
syn match mesonSpaceError display "\t\+ " |
| 80 |
endif |
| 81 |
|
| 82 |
" The default highlight links. Can be overridden later. |
| 83 |
hi def link mesonStatement Statement |
| 84 |
hi def link mesonConditional Conditional |
| 85 |
hi def link mesonRepeat Repeat |
| 86 |
hi def link mesonOperator Operator |
| 87 |
hi def link mesonComment Comment |
| 88 |
hi def link mesonTodo Todo |
| 89 |
hi def link mesonString String |
| 90 |
hi def link mesonEscape Special |
| 91 |
hi def link mesonNumber Number |
| 92 |
hi def link mesonBuiltin Function |
| 93 |
hi def link mesonBoolean Boolean |
| 94 |
if exists("meson_space_error_highlight") |
| 95 |
hi def link mesonSpaceError Error |
| 96 |
endif |
| 97 |
|
| 98 |
let b:current_syntax = "meson" |
| 99 |
|
| 100 |
let &cpo = s:cpo_save |
| 101 |
unlet s:cpo_save |
| 102 |
|
| 103 |
" vim:set sw=2 sts=2 ts=8 noet: |