From 4d49f180fdc8306265c5a28a2303483b7a90ce00 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" Date: Thu, 18 Jan 2018 10:23:09 +0100 Subject: [PATCH] Add support for Cmod files (used in Pike development). --- runtime/filetype.vim | 1 + runtime/syntax/cmod.vim | 76 +++++++++++++++++++++++++++++++++++++++++ runtime/syntax/pike.vim | 6 ++-- 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 runtime/syntax/cmod.vim diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 2f283a70784fc3..bca44e3c8f3a8a 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1154,6 +1154,7 @@ au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php " Pike au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike +au BufNewFile,BufRead *.cmod setf cmod " Pinfo config au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo diff --git a/runtime/syntax/cmod.vim b/runtime/syntax/cmod.vim new file mode 100644 index 00000000000000..42b1be0e9b3437 --- /dev/null +++ b/runtime/syntax/cmod.vim @@ -0,0 +1,76 @@ +" Vim syntax file +" Language: Cmod +" Current Maintainer: Stephen R. van den Berg +" Last Change: 2018 Jan 18 +" Remark: Is used to edit Cmod files for Pike development + +" quit when a syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" Read the C syntax to start with +runtime! syntax/c.vim +unlet b:current_syntax + +" For embedded Autodoc documentation +syn include @cmodAutodoc :p:h/autodoc.vim +unlet b:current_syntax + +" Supports rotating amongst several same-level preprocessor conditionals +packadd! matchit +let b:match_words = "^\s*#\s*\%(if\%(n\?def\)\|else\|el\%(se\)\?if\|endif\)\>" + +" Cmod extensions +syn keyword cmodStatement __INIT INIT EXIT GC_RECURSE GC_CHECK +syn keyword cmodStatement EXTRA OPTIMIZE RETURN +syn keyword cmodStatement ADD_EFUN ADD_EFUN2 ADD_FUNCTION +syn keyword cmodStatement MK_STRING MK_STRING_SVALUE CONSTANT_STRLEN + +syn keyword cmodAccess public protected private INHERIT +syn keyword cmodAccess CTYPE CVAR PIKEVAR PIKEFUN + +syn keyword cmodModifier efun export flags optflags optfunc +syn keyword cmodModifier type rawtype errname name c_name prototype +syn keyword cmodModifier program_flags gc_trivial + +syn keyword cmodType bool mapping string multiset array mixed +syn keyword cmodType object function program auto +syn keyword cmodType bignum longest zero +syn keyword cmodType this this_program + +syn keyword cmodOperator _destruct create __hash _sizeof _indices _values +syn keyword cmodOperator _is_type _sprintf _equal _m_delete _get_iterator +syn keyword cmodOperator _search _types _serialize _deserialize +syn keyword cmodOperator _size_object _random _sqrt + +syn keyword cmodStructure DECLARATIONS PIKECLASS DECLARE_STORAGE + +syn match cmodAutodocReal display contained "!.*" contains=@cmodAutodoc containedin=cComment,cCommentL +syn cluster cCommentGroup add=cmodAutodocReal +syn cluster cPreProcGroup add=cmodAutodocReal + +" Default highlighting +hi def link cmodAccess Statement +hi def link cmodCast Statement +hi def link cmodExceptions Exception +hi def link cmodOperator Operator +hi def link cmodStatement Statement +hi def link cmodModifier Type +hi def link cmodType Type +hi def link cmodStorageClass StorageClass +hi def link cmodStructure Structure +hi def link cmodBoolean Boolean +hi def link cmodConstant Constant +hi def link cmodRawStringDelimiter Delimiter +hi def link cmodRawString String +hi def link cmodNumber Number + +let b:current_syntax = "cmod" + +let &cpo = s:cpo_save +unlet s:cpo_save +" vim: ts=8 diff --git a/runtime/syntax/pike.vim b/runtime/syntax/pike.vim index 574356fbbe2562..fcd4444f3f68ce 100644 --- a/runtime/syntax/pike.vim +++ b/runtime/syntax/pike.vim @@ -110,7 +110,7 @@ syn region pikeNest transparent start="(<" end=">)" contains=@pikeExpr,pikeBadCl syn match pikeBadContinuation contained "\\\s\+$" " pikeCommentGroup allows adding matches for special things in comments -syn cluster pikeCommentGroup contains=pikeTodo,pikeBadContinuation,pikeAutodocReal +syn cluster pikeCommentGroup contains=pikeTodo,pikeBadContinuation " String and Character constants " Highlight special characters (those which have a backslash) differently @@ -280,11 +280,13 @@ endif syn region pikeIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeDelimiterDQ keepend syn match pikeIncluded display contained "<[^>]*>" syn match pikeInclude display "^\s*\zs#\s*include\>\s*["<]" contains=pikeIncluded -syn cluster pikePreProcGroup contains=pikeIncluded,pikeInclude,pikeEmbeddedString,pikeAutodocReal,pikeUserLabel,pikeCppOutWrapper,pikeCppInWrapper,@pikeCppOutInGroup,pikeFormat,pikeMlString,pikeCommentStartError,pikeMappIndex,pikeBadClose,pikeWord +syn cluster pikePreProcGroup contains=pikeIncluded,pikeInclude,pikeEmbeddedString,pikeUserLabel,pikeCppOutWrapper,pikeCppInWrapper,@pikeCppOutInGroup,pikeFormat,pikeMlString,pikeCommentStartError,pikeMappIndex,pikeBadClose,pikeWord syn region pikeDefine start="^\s*\zs#\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=@pikeStmts,@pikeExpr,pikeBadClose syn region pikePreProc start="^\s*\zs#\s*\%(pragma\|charset\|pike\|require\|string\|line\|warning\|error\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix,@Spell,pikeConstant syn match pikeAutodocReal display contained "!.*" contains=@pikeAutodoc containedin=pikeComment,pikeCommentL +syn cluster pikeCommentGroup add=pikeAutodocReal +syn cluster pikePreProcGroup add=pikeAutodocReal " Highlight User Labels " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'