Wu, Zhenyu | 62c09e0 | 2024-04-14 20:34:22 +0200 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: cmakecache - CMakeCache.txt files generated by CMake |
| 3 | " Author: bfrg <https://github.com/bfrg> |
| 4 | " Upstream: https://github.com/bfrg/vim-cmakecache-syntax |
| 5 | " Last Change: Nov 28, 2019 |
| 6 | " License: Same as Vim itself (see :h license) |
| 7 | |
| 8 | if exists('b:current_syntax') |
| 9 | finish |
| 10 | endif |
| 11 | |
| 12 | let s:cpo_save = &cpoptions |
| 13 | set cpoptions&vim |
| 14 | |
| 15 | " Comments start with # or // |
| 16 | syntax region CMakeCacheComment start="#\|//" end="$" |
| 17 | |
| 18 | " Match 'key' in key:type=value |
| 19 | syntax match CMakeCacheKey "^\s*\w\+\(-ADVANCED\)\=:"me=e-1 |
| 20 | |
| 21 | " Highlight 'str' in key:STRING=str (many thanks to Nickspoons in #vim!) |
| 22 | syntax region CMakeCacheStringVar matchgroup=CMakeCacheType start=":STRING="ms=s+1,rs=e-1 end="$" contains=CMakeCacheString keepend |
| 23 | syntax region CMakeCacheString start="="ms=s+1 end="$" contained |
| 24 | |
| 25 | " Highlight boolean 'value' in key:BOOL=value |
| 26 | syntax region CMakeCacheBoolVar matchgroup=CMakeCacheType start=":BOOL="ms=s+1,rs=e-1 end="$" contains=CMakeCacheBool keepend |
| 27 | syntax region CMakeCacheBool start="="ms=s+1 end="$" contained |
| 28 | |
| 29 | " Highlight 'path' in key:PATH=path |
| 30 | syntax region CMakeCachePathVar matchgroup=CMakeCacheType start=":PATH="ms=s+1,rs=e-1 end="$" contains=CMakeCachePath keepend |
| 31 | syntax region CMakeCachePath start="="ms=s+1 end="$" contained |
| 32 | |
| 33 | " Highlight 'file' in key:FILEPATH=file |
| 34 | syntax region CMakeCacheFilePathVar matchgroup=CMakeCacheType start=":FILEPATH="ms=s+1,rs=e-1 end="$" contains=CMakeCacheFilePath keepend |
| 35 | syntax region CMakeCacheFilePath start="="ms=s+1 end="$" contained |
| 36 | |
| 37 | " Highlight 'value' in key:STATIC=value |
| 38 | syntax region CMakeCacheStaticVar matchgroup=CMakeCacheType start=":STATIC="ms=s+1,rs=e-1 end="$" contains=CMakeCacheStatic keepend |
| 39 | syntax region CMakeCacheStatic start="="ms=s+1 end="$" contained |
| 40 | |
| 41 | " Highlight 'value' in key:Internal=value |
| 42 | syntax region CMakeCacheInternalVar matchgroup=CMakeCacheType start=":INTERNAL="ms=s+1,rs=e-1 end="$" contains=CMakeCacheInternal keepend |
| 43 | syntax region CMakeCacheInternal start="="ms=s+1 end="$" contained |
| 44 | |
| 45 | hi def link CMakeCacheComment Comment |
| 46 | hi def link CMakeCacheKey Identifier |
| 47 | hi def link CMakeCacheString String |
| 48 | hi def link CMakeCacheBool Constant |
| 49 | hi def link CMakeCachePath Directory |
| 50 | hi def link CMakeCacheFilePath Normal |
| 51 | hi def link CMakeCacheStatic Normal |
| 52 | hi def link CMakeCacheInternal Normal |
| 53 | |
| 54 | " Highlight 'type' in key:type=value |
| 55 | hi def link CMakeCacheType Type |
| 56 | |
| 57 | let b:current_syntax = 'cmakecache' |
| 58 | |
| 59 | let &cpoptions = s:cpo_save |
| 60 | unlet s:cpo_save |