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
This commit is contained in:
Matthias Krack 2023-12-12 17:34:34 +01:00
parent 47e8414d44
commit 472c987a54

View file

@ -75,6 +75,7 @@ syn keyword cp2kConstant <xsl:value-of select="NAME"/>
syn keyword cp2kSection <xsl:value-of select="NAME"/>
</xsl:for-each-group>
syn keyword cp2kSection END
syn keyword cp2kSection ENDIF
syn match cp2kBegSection '^\s*&amp;\w\+' contains=cp2kSection
syn match cp2kEndSection '^\s*&amp;END\s*\w\+' contains=cp2kSection
@ -92,7 +93,7 @@ syn keyword cp2kKeyword <xsl:value-of select="NAME"/>
" 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=~&amp;END,0=#,0=@
setlocal indentkeys+=0=~&amp;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*&amp;'
if line =~ '^\s*\c\%(&amp;\|@IF\)'
let ind += &amp;shiftwidth
if line =~ '^\s*\c\%(&amp;END\)\>'
if line =~ '^\s*\c\%(&amp;END\|@ENDIF\)\>'
let ind -= &amp;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\%(&amp;END\)\>'
if line =~ '^\s*\c\%(&amp;END\|@ENDIF\)\>'
let ind -= &amp;shiftwidth
elseif line =~ '^\s*@'
let ind = 0
endif
return ind
endfunction