Skip to content

Commit

Permalink
Add support for Cmod files (used in Pike development).
Browse files Browse the repository at this point in the history
  • Loading branch information
BuGlessRB committed Jan 18, 2018
1 parent 829179d commit 4d49f18
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
1 change: 1 addition & 0 deletions runtime/filetype.vim
Expand Up @@ -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
Expand Down
76 changes: 76 additions & 0 deletions runtime/syntax/cmod.vim
@@ -0,0 +1,76 @@
" Vim syntax file
" Language: Cmod
" Current Maintainer: Stephen R. van den Berg <srb@cuci.nl>
" 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 <sfile>: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
6 changes: 4 additions & 2 deletions runtime/syntax/pike.vim
Expand Up @@ -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
Expand Down Expand Up @@ -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 ':'
Expand Down

0 comments on commit 4d49f18

Please sign in to comment.