From 5316b82ebc6b1df8d168b564a2ff0dce1d1d8b3b Mon Sep 17 00:00:00 2001 From: Kevin Godby Date: Sun, 25 Jun 2017 15:12:04 -0500 Subject: [PATCH 1/2] Support CMake scripts CMake has the following end-wise pairings: * `foreach()` / `endforeach()` * `function()` / `endfunction()` * `if()` / `endif()` * `macro()` / `endmacro()` * `while()` / `endwhile()` The `end` forms can take an optional argument, though the argument is ignored. This code leaves that argument empty. CMake's commands are case-insensitive (e.g., `function()`, `Function()`, `FUNCTION()`, and `fUnCtIoN()` are all equivalent). This code will maintain the case of the opening command and prefix `END` if any only if the command is written in ALL CAPS. In all other cases (i.e., the command is written in lowercase or mixed case), `end` will be prefixed. Examples: ```cmake if(SOME_CONDITION) # ... endif() Function(MyFunction) # ... endFunction() WHILE(TRUE) # ... ENDWHILE() ``` --- plugin/endwise.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/endwise.vim b/plugin/endwise.vim index 67d57b1..0272664 100644 --- a/plugin/endwise.vim +++ b/plugin/endwise.vim @@ -67,6 +67,11 @@ augroup endwise " {{{1 \ let b:endwise_addition = 'endsnippet' | \ let b:endwise_words = 'snippet' | \ let b:endwise_syngroups = 'snipSnippet,snipSnippetHeader,snipSnippetHeaderKeyword' + autocmd FileType cmake + \ let b:endwise_addition = '\=submatch(0)==#toupper(submatch(0)) ? "END".submatch(0)."()" : "end".submatch(0)."()"' | + \ let b:endwise_words = 'foreach,function,if,macro,while' | + \ let b:endwise_pattern = '\%(\.*\)\@' | + \ let b:endwise_syngroups = 'cmakeStatement' autocmd FileType * call s:abbrev() augroup END " }}}1 From b0bd65f4ac427c46502e04b03c56fe8f7d7fbb7f Mon Sep 17 00:00:00 2001 From: "Kevin M. Godby" Date: Sun, 25 Jun 2017 15:30:33 -0500 Subject: [PATCH 2/2] Added support for newer CMake syntax group names. --- plugin/endwise.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/endwise.vim b/plugin/endwise.vim index 0272664..9c22408 100644 --- a/plugin/endwise.vim +++ b/plugin/endwise.vim @@ -71,7 +71,7 @@ augroup endwise " {{{1 \ let b:endwise_addition = '\=submatch(0)==#toupper(submatch(0)) ? "END".submatch(0)."()" : "end".submatch(0)."()"' | \ let b:endwise_words = 'foreach,function,if,macro,while' | \ let b:endwise_pattern = '\%(\.*\)\@' | - \ let b:endwise_syngroups = 'cmakeStatement' + \ let b:endwise_syngroups = 'cmakeStatement,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommand' autocmd FileType * call s:abbrev() augroup END " }}}1