mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 14:19:59 -05:00
vim-cmake-syntax 2025-07-28 (3c8cd401)
Code extracted from:
https://github.com/pboettch/vim-cmake-syntax.git
at commit 3c8cd4013fee999e1faa5c6444f946811603aaa3 (master).
Upstream Shortlog
-----------------
Craig Scott (1):
589a68db Fix typo in dependency provider method keyword
Eisuke Kawashima (1):
0fe3a3dd fix: add undo_indent
Patrick Boettcher (1):
08fa8f49 update to cmake version 4.1.20250715-g2c3f83a
cos (9):
4b296b4b fix update instructions
6d4dbe64 silence vint linter
d43f2050 silence perlcritic linter
2b98e3b3 fix bash shebang for test runner
396c7afc silence shellcheck + yamllint
57a7c831 improve test portability
13d84b42 add syntax folding
c18bb8ec regenerate for folding
3c8cd401 typofix
namniav (1):
6b667c41 Fix syntax highlighting for bracket arguments and comments
This commit is contained in:
committed by
Brad King
parent
1594a34250
commit
84dc53ad61
+28
-19
@@ -13,16 +13,25 @@
|
|||||||
" https://cmake.org/licensing
|
" https://cmake.org/licensing
|
||||||
" This implies that distribution with Vim is allowed
|
" This implies that distribution with Vim is allowed
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists('b:current_syntax')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let s:keepcpo= &cpo
|
let s:keepcpo= &cpoptions
|
||||||
set cpo&vim
|
set cpoptions&vim
|
||||||
|
|
||||||
syn region cmakeBracketArgument start="\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
|
syn cluster cmakeControl contains=
|
||||||
|
\ cmakeIf,
|
||||||
|
\ cmakeElse,
|
||||||
|
\ cmakeForeach,
|
||||||
|
\ cmakeWhile,
|
||||||
|
\ cmakeBlock,
|
||||||
|
\ cmakeFunction,
|
||||||
|
\ cmakeMacro
|
||||||
|
|
||||||
syn region cmakeComment start="#" end="$" contains=cmakeTodo,@Spell
|
syn region cmakeBracketArgument start="\[\z(=*\)\[" end="\]\z1\]" fold contains=cmakeTodo,@Spell
|
||||||
syn region cmakeBracketComment start="\[\z(=*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
|
|
||||||
|
syn region cmakeComment start="#\(\[=*\[\)\@!" end="$" contains=cmakeTodo,@Spell
|
||||||
|
syn region cmakeBracketComment start="#\[\z(=*\)\[" end="\]\z1\]" fold contains=cmakeTodo,@Spell
|
||||||
|
|
||||||
syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
|
syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
|
||||||
syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
|
syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
|
||||||
@@ -35,7 +44,15 @@ syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmak
|
|||||||
|
|
||||||
syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
|
syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
|
||||||
|
|
||||||
syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeGeneratorExpressions,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo,@Spell
|
syn region cmakeArguments start="(" end=")" contains=ALLBUT,@cmakeControl,cmakeGeneratorExpressions,cmakeCommand,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo,@Spell fold
|
||||||
|
syn region cmakeIf matchgroup=cmakeKeyword start=/^\s*\<if\>/ end=/^\s*\<endif\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
syn match cmakeElse /^\s*\<else\(if\)\?\>/ contained contains=NONE
|
||||||
|
|
||||||
|
syn region cmakeForeach matchgroup=cmakeKeyword start=/^\s*\<foreach\>/ end=/^\s*\<endforeach\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
syn region cmakeWhile matchgroup=cmakeKeyword start=/^\s*\<while\>/ end=/^\s*\<endwhile\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
syn region cmakeFunction matchgroup=cmakeKeyword start=/^\s*\<function\>/ end=/^\s*\<endfunction\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
syn region cmakeBlock matchgroup=cmakeKeyword start=/^\s*\<block\>/ end=/^\s*\<endblock\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
syn region cmakeMacro matchgroup=cmakeKeyword start=/^\s*\<macro\>/ end=/^\s*\<endmacro\>/ transparent fold contains=@cmakeControl,cmakeArguments
|
||||||
|
|
||||||
syn case match
|
syn case match
|
||||||
|
|
||||||
@@ -59,14 +76,6 @@ syn keyword cmakeCommand
|
|||||||
@COMMAND_LIST@
|
@COMMAND_LIST@
|
||||||
\ nextgroup=cmakeArguments
|
\ nextgroup=cmakeArguments
|
||||||
|
|
||||||
syn keyword cmakeCommandConditional
|
|
||||||
@CONDITIONALS@
|
|
||||||
\ nextgroup=cmakeArguments
|
|
||||||
|
|
||||||
syn keyword cmakeCommandRepeat
|
|
||||||
@LOOPS@
|
|
||||||
\ nextgroup=cmakeArguments
|
|
||||||
|
|
||||||
syn keyword cmakeCommandDeprecated
|
syn keyword cmakeCommandDeprecated
|
||||||
@DEPRECATED@
|
@DEPRECATED@
|
||||||
\ nextgroup=cmakeArguments
|
\ nextgroup=cmakeArguments
|
||||||
@@ -80,14 +89,14 @@ syn keyword cmakeTodo
|
|||||||
hi def link cmakeBracketArgument String
|
hi def link cmakeBracketArgument String
|
||||||
hi def link cmakeBracketComment Comment
|
hi def link cmakeBracketComment Comment
|
||||||
hi def link cmakeCommand Function
|
hi def link cmakeCommand Function
|
||||||
hi def link cmakeCommandConditional Conditional
|
|
||||||
hi def link cmakeCommandDeprecated WarningMsg
|
hi def link cmakeCommandDeprecated WarningMsg
|
||||||
hi def link cmakeCommandRepeat Repeat
|
|
||||||
hi def link cmakeComment Comment
|
hi def link cmakeComment Comment
|
||||||
|
hi def link cmakeElse Conditional
|
||||||
hi def link cmakeEnvironment Special
|
hi def link cmakeEnvironment Special
|
||||||
hi def link cmakeEscaped Special
|
hi def link cmakeEscaped Special
|
||||||
hi def link cmakeGeneratorExpression WarningMsg
|
hi def link cmakeGeneratorExpression WarningMsg
|
||||||
hi def link cmakeGeneratorExpressions Constant
|
hi def link cmakeGeneratorExpressions Constant
|
||||||
|
hi def link cmakeKeyword Conditional
|
||||||
hi def link cmakeModule Include
|
hi def link cmakeModule Include
|
||||||
hi def link cmakeProperty Constant
|
hi def link cmakeProperty Constant
|
||||||
hi def link cmakeRegistry Underlined
|
hi def link cmakeRegistry Underlined
|
||||||
@@ -122,9 +131,9 @@ hi def link cmakeKWconfigure_package_config_file ModeMsg
|
|||||||
hi def link cmakeKWwrite_basic_package_version_file ModeMsg
|
hi def link cmakeKWwrite_basic_package_version_file ModeMsg
|
||||||
hi def link cmakeKWconfigure_package_config_file_constants Constant
|
hi def link cmakeKWconfigure_package_config_file_constants Constant
|
||||||
|
|
||||||
let b:current_syntax = "cmake"
|
let b:current_syntax = 'cmake'
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
let &cpoptions = s:keepcpo
|
||||||
unlet s:keepcpo
|
unlet s:keepcpo
|
||||||
|
|
||||||
" vim: set nowrap:
|
" vim: set nowrap:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ my %unwanted = map { $_ => 1 } qw(VS CXX IDE NOTFOUND NO_ DFOO DBAR NEW GNU);
|
|||||||
|
|
||||||
# control-statements
|
# control-statements
|
||||||
my %conditional = map { $_ => 1 } qw(if else elseif endif);
|
my %conditional = map { $_ => 1 } qw(if else elseif endif);
|
||||||
my %loop = map { $_ => 1 } qw(foreach while endforeach endwhile);
|
my %loopetc = map { $_ => 1 } qw(block foreach function macro while endblock endfunction endforeach endmacro endwhile);
|
||||||
|
|
||||||
# decrecated
|
# decrecated
|
||||||
my %deprecated = map { $_ => 1 } qw(build_name exec_program export_library_dependencies install_files install_programs install_targets link_libraries make_directory output_required_files remove subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file);
|
my %deprecated = map { $_ => 1 } qw(build_name exec_program export_library_dependencies install_files install_programs install_targets link_libraries make_directory output_required_files remove subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file);
|
||||||
@@ -141,7 +141,7 @@ while(<IN>)
|
|||||||
if ($1 eq "COMMAND_LIST") {
|
if ($1 eq "COMMAND_LIST") {
|
||||||
# do not include "special" commands in this list
|
# do not include "special" commands in this list
|
||||||
my @tmp = grep { ! exists $conditional{$_} and
|
my @tmp = grep { ! exists $conditional{$_} and
|
||||||
! exists $loop{$_} and
|
! exists $loopetc{$_} and
|
||||||
! exists $deprecated{$_} } @commands;
|
! exists $deprecated{$_} } @commands;
|
||||||
print_list(\*OUT, @tmp);
|
print_list(\*OUT, @tmp);
|
||||||
} elsif ($1 eq "VARIABLE_LIST") {
|
} elsif ($1 eq "VARIABLE_LIST") {
|
||||||
@@ -150,10 +150,6 @@ while(<IN>)
|
|||||||
print_list(\*OUT, @modules);
|
print_list(\*OUT, @modules);
|
||||||
} elsif ($1 eq "GENERATOR_EXPRESSIONS") {
|
} elsif ($1 eq "GENERATOR_EXPRESSIONS") {
|
||||||
print_list(\*OUT, @generator_expr);
|
print_list(\*OUT, @generator_expr);
|
||||||
} elsif ($1 eq "CONDITIONALS") {
|
|
||||||
print_list(\*OUT, keys %conditional);
|
|
||||||
} elsif ($1 eq "LOOPS") {
|
|
||||||
print_list(\*OUT, keys %loop);
|
|
||||||
} elsif ($1 eq "DEPRECATED") {
|
} elsif ($1 eq "DEPRECATED") {
|
||||||
print_list(\*OUT, keys %deprecated);
|
print_list(\*OUT, keys %deprecated);
|
||||||
} elsif ($1 eq "PROPERTIES") {
|
} elsif ($1 eq "PROPERTIES") {
|
||||||
|
|||||||
+7
-5
@@ -9,19 +9,21 @@
|
|||||||
" https://cmake.org/licensing
|
" https://cmake.org/licensing
|
||||||
" This implies that distribution with Vim is allowed
|
" This implies that distribution with Vim is allowed
|
||||||
|
|
||||||
if exists("b:did_indent")
|
if exists('b:did_indent')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let b:did_indent = 1
|
let b:did_indent = 1
|
||||||
|
|
||||||
let s:keepcpo= &cpo
|
let s:keepcpo= &cpoptions
|
||||||
set cpo&vim
|
set cpoptions&vim
|
||||||
|
|
||||||
setlocal indentexpr=CMakeGetIndent(v:lnum)
|
setlocal indentexpr=CMakeGetIndent(v:lnum)
|
||||||
setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
|
setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
|
||||||
|
|
||||||
|
let b:undo_indent = "setl inde< indk<"
|
||||||
|
|
||||||
" Only define the function once.
|
" Only define the function once.
|
||||||
if exists("*CMakeGetIndent")
|
if exists('*CMakeGetIndent')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -85,5 +87,5 @@ fun! CMakeGetIndent(lnum)
|
|||||||
return ind
|
return ind
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
let &cpoptions = s:keepcpo
|
||||||
unlet s:keepcpo
|
unlet s:keepcpo
|
||||||
|
|||||||
+585
-80
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user