From 472c987a547e0bfdeb9b06b2d522b8aa5fcddca2 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Tue, 12 Dec 2023 17:34:34 +0100 Subject: [PATCH] Update vim syntax file generation - Recognize XCTYPE macro keyword - Indent macro kewords like sections, keywords, and comments - Indent body of @IF/@ENDIF block like &SECTION/&END --- tools/input_editing/vim/vim.xsl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/input_editing/vim/vim.xsl b/tools/input_editing/vim/vim.xsl index 6024c76d28..d5800b3ec6 100644 --- a/tools/input_editing/vim/vim.xsl +++ b/tools/input_editing/vim/vim.xsl @@ -75,6 +75,7 @@ syn keyword cp2kConstant syn keyword cp2kSection syn keyword cp2kSection END +syn keyword cp2kSection ENDIF syn match cp2kBegSection '^\s*&\w\+' contains=cp2kSection syn match cp2kEndSection '^\s*&END\s*\w\+' contains=cp2kSection @@ -92,7 +93,7 @@ syn keyword cp2kKeyword " CP2K preprocessing directives "-----------------------------------------------------------------/ -syn keyword cp2kPreProc endif if include set +syn keyword cp2kPreProc endif if include set xctype "-----------------------------------------------------------------/ " CP2K strings @@ -119,7 +120,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetCp2kIndent() -setlocal indentkeys+=0=~&END,0=#,0=@ +setlocal indentkeys+=0=~&END,0=~@ENDIF,0=#,0=@ setlocal nosmartindent if exists("*GetCp2kIndent") @@ -133,23 +134,15 @@ function! GetCp2kIndent() endif let ind = indent(lnum) let line = getline(lnum) - if line =~ '^\s*&' + if line =~ '^\s*\c\%(&\|@IF\)' let ind += &shiftwidth - if line =~ '^\s*\c\%(&END\)\>' + if line =~ '^\s*\c\%(&END\|@ENDIF\)\>' let ind -= &shiftwidth endif - elseif line =~ '^\s*\c\%(@if\|@endif\|@include\|@set\)\>' - let plnum = lnum - while getline(plnum) =~ '^\s*@' - let plnum -= 1 - endwhile - let ind = indent(plnum) endif let line = getline(v:lnum) - if line =~ '^\s*\c\%(&END\)\>' + if line =~ '^\s*\c\%(&END\|@ENDIF\)\>' let ind -= &shiftwidth - elseif line =~ '^\s*@' - let ind = 0 endif return ind endfunction