" Vim syntax file " Language: CP2K input files " Maintainer: based on work by Alin M Elena available at https://gitorious.org/cp2k-vim " Revision: 13th of September 2010 " History: " - XSLT dump and improved syntax highlighting (10.12.2013, Matthias Krack) " - Folding and automatic indentation added (13.12.2013, Matthias Krack) " - Remove folding since it overrides user's defaults (18.11.2016, Patrick Seewald) " CP2K-Version: () if exists("b:current_syntax") finish endif let b:current_syntax = "cp2k" syn case ignore "----------------------------------------------------------------/ " CP2K numbers used in blocks "----------------------------------------------------------------/ " Regular int like number with - + or nothing in front " e.g. 918, or -49 syn match cp2kNumber '\d\+' syn match cp2kNumber '[-+]\d\+' " Floating point number with decimal no E or e (+,-) " e.g. 0.198781, or -3.141592 syn match cp2kNumber '\d\+\.\d*' syn match cp2kNumber '[-+]\d\+\.\d*' " Floating point like number with E and no decimal point (+,-) " e.g. 3E+9, 3e+09, or -3e+02 syn match cp2kNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' syn match cp2kNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' " Floating point like number with E and decimal point (+,-) " e.g. -3.9188e+09, or 0.9188E-93 syn match cp2kNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' syn match cp2kNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' "----------------------------------------------------------------/ " CP2K Boolean entities "----------------------------------------------------------------/ syn keyword cp2kBool true false T F yes no "-----------------------------------------------------------------/ " CP2K comments "-----------------------------------------------------------------/ syn keyword cp2kTodo TODO FIXME NOTE REMARK syn match cp2kComment "#.*$" contains=cp2kTodo syn match cp2kComment "!.*$" contains=cp2kTodo "----------------------------------------------------------------/ " CP2K predefined constants "----------------------------------------------------------------/ syn keyword cp2kConstant "----------------------------------------------------------------/ " CP2K sections "----------------------------------------------------------------/ 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 "----------------------------------------------------------------/ " CP2K default keyword names "----------------------------------------------------------------/ syn keyword cp2kKeyword "----------------------------------------------------------------/ " CP2K alias keyword names "----------------------------------------------------------------/ syn keyword cp2kKeyword "-----------------------------------------------------------------/ " CP2K preprocessing directives "-----------------------------------------------------------------/ syn keyword cp2kPreProc ENDIF FFTYPE IF INCLUDE PRINT SET XCTYPE "-----------------------------------------------------------------/ " CP2K strings "-----------------------------------------------------------------/ syn region cp2kString matchgroup=cp2kStringDelimiter start=+"+ end=+"+ syn region cp2kString matchgroup=cp2kStringDelimiter start=+'+ end=+'+ syn region cp2kString matchgroup=cp2kStringDelimiter start=+`+ end=+`+ "----------------------------------------------------------------------------/ " Final setup "----------------------------------------------------------------------------/ setlocal autoindent setlocal expandtab setlocal iskeyword+=- "----------------------------------------------------------------------------/ " Indentation support for CP2K input syntax "----------------------------------------------------------------------------/ if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetCp2kIndent() setlocal indentkeys+=0=~&END,0=~@ENDIF,0=#,0=@ setlocal nosmartindent if exists("*GetCp2kIndent") finish endif function! GetCp2kIndent() let lnum = prevnonblank(v:lnum - 1) if lnum == 0 return 0 endif let ind = indent(lnum) let line = getline(lnum) if line =~ '^\s*\c\%(&\|@IF\)' let ind += &shiftwidth if line =~ '^\s*\c\%(&END\|@ENDIF\)\>' let ind -= &shiftwidth endif endif let line = getline(v:lnum) if line =~ '^\s*\c\%(&END\|@ENDIF\)\>' let ind -= &shiftwidth endif return ind endfunction "----------------------------------------------------------------------------/ " CP2K keyword highlighting rules "----------------------------------------------------------------------------/ hi def link cp2kComment Comment hi def link cp2kConstant Constant hi def link cp2kTodo Todo hi def link cp2kBool Boolean hi def link cp2kNumber Number hi def link cp2kKeyword Keyword hi def link cp2kSection Structure hi def link cp2kPreProc PreProc hi def link cp2kString String hi def link cp2kStringDelimiter Delimiter