Skip to content

Commit 62c09e0

Browse files
Freed-Wubfrg
authored andcommitted
patch 9.1.0325: filetype: CMakeCache.txt files not recognized
Problem: filetype: CMakeCache.txt files not recognized Solution: Detect 'CMakeCache.txt' files as cmakecache filetype, include basic syntax script for cmakecache (Wu, Zhenyu, @bfrg) closes: #14384 Co-authored-by: bfrg <bfrg@users.noreply.github.com> Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 4ba70ca commit 62c09e0

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

runtime/filetype.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ au BufNewFile,BufRead *.clj,*.cljs,*.cljx,*.cljc setf clojure
449449
" Cmake
450450
au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake
451451

452+
" CmakeCache
453+
autocmd BufRead,BufNewFile CMakeCache.txt setf cmakecache
454+
452455
" Cmusrc
453456
au BufNewFile,BufRead */.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
454457
au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc

runtime/syntax/cmakecache.vim

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

src/testdir/test_filetype.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def s:GetFilenameChecks(): dict<list<string>>
157157
clean: ['file.dcl', 'file.icl'],
158158
clojure: ['file.clj', 'file.cljs', 'file.cljx', 'file.cljc', 'init.trans', 'any/etc/translate-shell', '.trans'],
159159
cmake: ['CMakeLists.txt', 'file.cmake', 'file.cmake.in'],
160+
cmakecache: ['CMakeCache.txt'],
160161
cmod: ['file.cmod'],
161162
cmusrc: ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
162163
cobol: ['file.cbl', 'file.cob', 'file.lib'],

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
325,
707709
/**/
708710
324,
709711
/**/

0 commit comments

Comments
 (0)