diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 2f283a70784fc..288d0e59b4e36 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -239,6 +239,7 @@ endif " C or lpc au BufNewFile,BufRead *.c call dist#ft#FTlpc() +au BufNewFile,BufRead *.lpc,*.ulpc setf lpc " Calendar au BufNewFile,BufRead calendar setf calendar @@ -1153,7 +1154,8 @@ au BufNewFile,BufRead *.pod6 setf pod6 au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php " Pike -au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike +au BufNewFile,BufRead *.pike,*.pmod setf pike +au BufNewFile,BufRead *.cmod setf cmod " Pinfo config au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo diff --git a/runtime/scripts.vim b/runtime/scripts.vim index 18263e2842c57..71e3f48bdfcda 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -100,6 +100,10 @@ if s:line1 =~# "^#!" elseif s:name =~# 'make\>' set ft=make + " Pike + elseif s:name =~# '^pike\%(\>\|[0-9]\)' + set ft=pike + " Lua elseif s:name =~# 'lua' set ft=lua diff --git a/runtime/syntax/autodoc.vim b/runtime/syntax/autodoc.vim new file mode 100644 index 0000000000000..67a627e46ce56 --- /dev/null +++ b/runtime/syntax/autodoc.vim @@ -0,0 +1,101 @@ +" Vim syntax file +" Language: Autodoc +" Maintainer: Stephen R. van den Berg +" Last Change: 2018 Jan 23 +" Version: 2.9 +" Remark: Included by pike.vim, cmod.vim and optionally c.vim +" Remark: In order to make c.vim use it, set: c_autodoc + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +syn case match + +" A bunch of useful autodoc keywords +syn keyword autodocStatement contained appears belongs global +syn keyword autodocStatement contained decl directive inherit +syn keyword autodocStatement contained deprecated obsolete bugs +syn keyword autodocStatement contained copyright example fixme note param returns +syn keyword autodocStatement contained seealso thanks throws constant +syn keyword autodocStatement contained member index elem +syn keyword autodocStatement contained value type item + +syn keyword autodocRegion contained enum mapping code multiset array +syn keyword autodocRegion contained int string section mixed ol ul dl +syn keyword autodocRegion contained class module namespace +syn keyword autodocRegion contained endenum endmapping endcode endmultiset +syn keyword autodocRegion contained endarray endint endstring endsection +syn keyword autodocRegion contained endmixed endol endul enddl +syn keyword autodocRegion contained endclass endmodule endnamespace + +syn keyword autodocIgnore contained ignore endignore + +syn keyword autodocStatAcc contained b i u tt url pre sub sup +syn keyword autodocStatAcc contained ref rfc xml dl expr image + +syn keyword autodocTodo contained TODO FIXME XXX + +syn match autodocLineStart display "\(//\|/\?\*\)\@2<=!" +syn match autodocWords "[^!@{}[\]]\+" display contains=@Spell + +syn match autodocLink "@\[[^[\]]\+]"hs=s+2,he=e-1 display contains=autodocLead +syn match autodocAtStmt "@[a-z]\+\%(\s\|$\)\@="hs=s+1 display contains=autodocStatement,autodocIgnore,autodocLead,autodocRegion + +" Due to limitations of the matching algorithm, we cannot highlight +" nested autodocNStmtAcc structures correctly +syn region autodocNStmtAcc start="@[a-z]\+{" end="@}" contains=autodocStatAcc,autodocLead keepend + +syn match autodocUrl contained display ".\+" +syn region autodocAtUrlAcc start="{"ms=s+1 end="@}"he=e-1,me=e-2 contained display contains=autodocUrl,autodocLead keepend +syn region autodocNUrlAcc start="@url{" end="@}" contains=autodocStatAcc,autodocAtUrlAcc,autodocLead transparent + +syn match autodocSpecial "@@" display +syn match autodocLead "@" display contained + +"when wanted, highlight trailing white space +if exists("c_space_errors") + if !exists("c_no_trail_space_error") + syn match autodocSpaceError display excludenl "\s\+$" + endif + if !exists("c_no_tab_space_error") + syn match autodocSpaceError display " \+\t"me=e-1 + endif +endif + +if exists("c_minlines") + let b:c_minlines = c_minlines +else + if !exists("c_no_if0") + let b:c_minlines = 50 " #if 0 constructs can be long + else + let b:c_minlines = 15 " mostly for () constructs + endif +endif +exec "syn sync ccomment autodocComment minlines=" . b:c_minlines + +" Define the default highlighting. +" Only used when an item doesn't have highlighting yet +hi def link autodocStatement Statement +hi def link autodocStatAcc Statement +hi def link autodocRegion Structure +hi def link autodocAtStmt Error +hi def link autodocNStmtAcc Identifier +hi def link autodocLink Type +hi def link autodocTodo Todo +hi def link autodocSpaceError Error +hi def link autodocLineStart SpecialComment +hi def link autodocSpecial SpecialChar +hi def link autodocUrl Underlined +hi def link autodocLead Statement +hi def link autodocIgnore Delimiter + +let b:current_syntax = "autodoc" + +let &cpo = s:cpo_save +unlet s:cpo_save +" vim: ts=8 diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index f659a87b714fa..1e9d1aa029d7c 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -13,6 +13,14 @@ set cpo&vim let s:ft = matchstr(&ft, '^\([^.]\)\+') +" Optional embedded Autodoc parsing +" To enable it add: let g:c_autodoc=1 +" to your .vimrc +if exists("c_autodoc") + syn include @cAutodoc :p:h/autodoc.vim + unlet b:current_syntax +endif + " A bunch of useful C keywords syn keyword cStatement goto break return continue asm syn keyword cLabel case default @@ -377,6 +385,13 @@ syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInP syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +" Optional embedded Autodoc parsing +if exists("c_autodoc") + syn match cAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@cAutodoc containedin=cComment,cCommentL + syn cluster cCommentGroup add=cAutodocReal + syn cluster cPreProcGroup add=cAutodocReal +endif + " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString if s:ft ==# 'c' || exists("cpp_no_cpp11") diff --git a/runtime/syntax/cmod.vim b/runtime/syntax/cmod.vim new file mode 100644 index 0000000000000..ea37682ff64fb --- /dev/null +++ b/runtime/syntax/cmod.vim @@ -0,0 +1,144 @@ +" Vim syntax file +" Language: Cmod +" Current Maintainer: Stephen R. van den Berg +" Last Change: 2018 Jan 23 +" Version: 2.9 +" Remark: Is used to edit Cmod files for Pike development. +" Remark: Includes a highlighter for any embedded Autodoc format. + +" 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 + +if !exists("c_autodoc") + " For embedded Autodoc documentation + syn include @cmodAutodoc :p:h/autodoc.vim + unlet b:current_syntax +endif + +" Supports rotating amongst several same-level preprocessor conditionals +packadd! matchit +let b:match_words = "({:}\\@1<=),^\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 cmodStatement SET_SVAL pop_n_elems pop_stack +syn keyword cmodStatement SIMPLE_ARG_TYPE_ERROR Pike_sp Pike_fp MKPCHARP +syn keyword cmodStatement SET_SVAL_TYPE REF_MAKE_CONST_STRING INC_PCHARP +syn keyword cmodStatement PTR_FROM_INT INHERIT_FROM_PTR +syn keyword cmodStatement DECLARE_CYCLIC BEGIN_CYCLIC END_CYCLIC +syn keyword cmodStatement UPDATE_LOCATION UNSAFE_IS_ZERO SAFE_IS_ZERO +syn keyword cmodStatement MKPCHARP_STR APPLY_MASTER current_storage +syn keyword cmodStatement PIKE_MAP_VARIABLE size_shift +syn keyword cmodStatement THREADS_ALLOW THREADS_DISALLOW + +syn keyword cmodStatement add_integer_constant ref_push_object +syn keyword cmodStatement push_string apply_svalue free_svalue +syn keyword cmodStatement get_inherit_storage get_storage +syn keyword cmodStatement make_shared_binary_string push_int64 +syn keyword cmodStatement begin_shared_string end_shared_string +syn keyword cmodStatement add_ref fast_clone_object clone_object +syn keyword cmodStatement push_undefined push_int ref_push_string +syn keyword cmodStatement free_string push_ulongest free_object +syn keyword cmodStatement convert_stack_top_to_bignum push_array +syn keyword cmodStatement push_object reduce_stack_top_bignum +syn keyword cmodStatement push_static_text apply_current +syn keyword cmodStatement assign_svalue free_program destruct_object +syn keyword cmodStatement start_new_program low_inherit stack_swap +syn keyword cmodStatement generic_error_program end_program +syn keyword cmodStatement free_array apply_external copy_mapping +syn keyword cmodStatement push_constant_text ref_push_mapping +syn keyword cmodStatement mapping_insert mapping_string_insert_string +syn keyword cmodStatement f_aggregate_mapping f_aggregate apply +syn keyword cmodStatement push_mapping push_svalue low_mapping_lookup +syn keyword cmodStatement assign_svalues_no_free f_add +syn keyword cmodStatement push_empty_string stack_dup assign_lvalue +syn keyword cmodStatement low_mapping_string_lookup allocate_mapping +syn keyword cmodStatement copy_shared_string make_shared_binary_string0 +syn keyword cmodStatement f_call_function f_index f_utf8_to_string +syn keyword cmodStatement finish_string_builder init_string_builder +syn keyword cmodStatement reset_string_builder free_string_builder +syn keyword cmodStatement string_builder_putchar get_all_args +syn keyword cmodStatement add_shared_strings check_all_args +syn keyword cmodStatement do_inherit add_string_constant +syn keyword cmodStatement add_program_constant set_init_callback +syn keyword cmodStatement simple_mapping_string_lookup +syn keyword cmodStatement f_sprintf push_text string_has_null +syn keyword cmodStatement end_and_resize_shared_string + +syn keyword cmodStatement args sp + +syn keyword cmodStatement free + +syn keyword cmodConstant ID_PROTECTED ID_FINAL PIKE_DEBUG +syn keyword cmodConstant NUMBER_NUMBER +syn keyword cmodConstant PIKE_T_INT PIKE_T_STRING PIKE_T_ARRAY +syn keyword cmodConstant PIKE_T_MULTISET PIKE_T_OBJECT PIKE_T_MAPPING +syn keyword cmodConstant NUMBER_UNDEFINED PIKE_T_PROGRAM PIKE_T_FUNCTION +syn keyword cmodConstant T_OBJECT T_STRING T_ARRAY T_MAPPING + +syn keyword cmodException SET_ONERROR UNSET_ONERROR ONERROR +syn keyword cmodException CALL_AND_UNSET_ONERROR + +syn keyword cmodDebug Pike_fatal Pike_error check_stack + +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 PMOD_EXPORT +syn keyword cmodModifier ATTRIBUTE noclone noinline +syn keyword cmodModifier tOr tFuncV tInt tMix tVoid tStr tMap tPrg +syn keyword cmodModifier tSetvar tArr tMult tMultiset +syn keyword cmodModifier tArray tMapping tString tSetvar tVar + +syn keyword cmodType bool mapping string multiset array mixed +syn keyword cmodType object function program auto svalue +syn keyword cmodType bignum longest zero pike_string +syn keyword cmodType this this_program THIS INT_TYPE INT64 INT32 +syn keyword cmodType p_wchar2 PCHARP p_wchar1 p_wchar0 MP_INT + +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 TYPEOF SUBTYPEOF +syn keyword cmodOperator LIKELY UNLIKELY + +syn keyword cmodStructure DECLARATIONS PIKECLASS DECLARE_STORAGE + +if !exists("c_autodoc") + syn match cmodAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@cmodAutodoc containedin=cComment,cCommentL + syn cluster cCommentGroup add=cmodAutodocReal + syn cluster cPreProcGroup add=cmodAutodocReal +endif + +" Default highlighting +hi def link cmodAccess Statement +hi def link cmodOperator Operator +hi def link cmodStatement Statement +hi def link cmodConstant Constant +hi def link cmodModifier Type +hi def link cmodType Type +hi def link cmodStorageClass StorageClass +hi def link cmodStructure Structure +hi def link cmodException Exception +hi def link cmodDebug Debug + +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 ccd122c46c9d5..00928caba1f6c 100644 --- a/runtime/syntax/pike.vim +++ b/runtime/syntax/pike.vim @@ -1,59 +1,184 @@ " Vim syntax file -" Language: Pike -" Maintainer: Francesco Chemolli -" Last Change: 2001 May 10 +" Language: Pike +" Maintainer: Stephen R. van den Berg +" Previous Maintainer: Francesco Chemolli +" Last Change: 2018 Jan 23 +" Version: 2.9 +" Remark: Derived from the C-syntax; fixed several bugs in the C-syntax +" Remark: and extended it with the Pike syntax. +" Remark: Includes a highlighter for all Pike types of parenthesis errors. +" Remark: Includes a highlighter for SQL on multiline strings. +" Remark: Includes a highlighter for any embedded Autodoc format. -" quit when a syntax file was already loaded +" Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") finish endif -" A bunch of useful C keywords -syn keyword pikeStatement goto break return continue -syn keyword pikeLabel case default -syn keyword pikeConditional if else switch -syn keyword pikeRepeat while for foreach do -syn keyword pikeStatement gauge destruct lambda inherit import typeof -syn keyword pikeException catch -syn keyword pikeType inline nomask private protected public static +let s:cpo_save = &cpo +set cpo&vim +" For multiline strings, try formatting them as SQL +syn include @pikeSQL :p:h/sqloracle.vim +unlet b:current_syntax -syn keyword pikeTodo contained TODO FIXME XXX +" For embedded Autodoc documentation (WIP) +syn include @pikeAutodoc :p:h/autodoc.vim +unlet b:current_syntax + +syn case match + +" Supports array, multiset, mapping multi-character delimiter matching +" Supports rotating amongst several same-level preprocessor conditionals +packadd! matchit +let b:match_words = "({:}\\@1<=),(\\[:]\\@1<=),(<:>\\@1<=),^\s*#\s*\%(if\%(n\?def\)\|else\|el\%(se\)\?if\|endif\)\>" + +" A bunch of useful Pike keywords +syn keyword pikeDebug gauge backtrace describe_backtrace werror _Static_assert static_assert +syn keyword pikeException error catch throw +syn keyword pikeLabel case default break return continue +syn keyword pikeConditional if else switch +syn keyword pikeRepeat while for foreach do + +syn keyword pikePredef RegGetKeyNames RegGetValue RegGetValues +syn keyword pikePredef __automap__ __empty_program +syn keyword pikePredef __handle_sprintf_format __parse_pike_type _disable_threads +syn keyword pikePredef _do_call_outs _exit _gdb_breakpoint +syn keyword pikePredef abs access acos acosh add_constant alarm all_constants +syn keyword pikePredef array_sscanf asin asinh atan atan2 atanh atexit +syn keyword pikePredef basetype call_function call_out call_out_info cd ceil +syn keyword pikePredef combine_path combine_path_nt +syn keyword pikePredef combine_path_unix compile copy_value cos cosh cpp crypt +syn keyword pikePredef ctime decode_value delay encode_value encode_value_canonic +syn keyword pikePredef enumerate errno exece exit exp file_stat file_truncate +syn keyword pikePredef filesystem_stat find_call_out floor fork function_name +syn keyword pikePredef function_object function_program gc +syn keyword pikePredef get_active_compilation_handler get_active_error_handler +syn keyword pikePredef get_all_groups get_all_users get_dir get_groups_for_user +syn keyword pikePredef get_iterator get_profiling_info get_weak_flag getcwd +syn keyword pikePredef getgrgid getgrnam gethrdtime gethrtime gethrvtime getpid +syn keyword pikePredef getpwnam getpwuid getxattr glob gmtime has_index has_prefix +syn keyword pikePredef has_suffix has_value hash hash_7_0 hash_7_4 hash_8_0 +syn keyword pikePredef hash_value kill limit listxattr load_module localtime +syn keyword pikePredef log lower_case master max min mkdir mktime mv +syn keyword pikePredef object_program pow query_num_arg random_seed +syn keyword pikePredef remove_call_out removexattr replace_master rm round +syn keyword pikePredef set_priority set_weak_flag setxattr sgn signal signame +syn keyword pikePredef signum sin sinh sleep sort sprintf sqrt sscanf strerror +syn keyword pikePredef string_filter_non_unicode string_to_unicode string_to_utf8 +syn keyword pikePredef tan tanh time trace types ualarm unicode_to_string +syn keyword pikePredef upper_case utf8_to_string version + +syn keyword pikePredef write lock try_lock +syn keyword pikePredef MutexKey Timestamp Date Time TimeTZ Interval Inet Range +syn keyword pikePredef Null null inf nan + +syn keyword pikeTodo contained TODO FIXME XXX + +" Match parengroups: allows for highlighting indices of mappings and +" highlighting semicolons that are out of place due to a paren imbalance +syn cluster pikePreShort contains=pikeDefine,pikePreProc,pikeCppOutWrapper,pikeCppInWrapper,pikePreCondit,pikePreConditMatch +syn cluster pikeExprGroup contains=pikeMappIndex,@pikeStmt,pikeNest,@pikeBadGroup,pikeSoftCast +syn match pikeWord transparent contained /[^()'"[\]{},;:]\+/ contains=ALLBUT,@pikePreProcGroup,@pikeExprGroup +syn match pikeFirstWord transparent display contained /^\s*#[^()'"[\]{},;:]\+/ contains=@pikePreShort +syn cluster pikeMappElm contains=pikeMappIndex,@pikeStmt +syn cluster pikeStmt contains=pikeFirstWord,pikeCharacter,pikeString,pikeMlString,pikeWord,pikeNest +syn cluster pikeBadGroup contains=pikeBadPClose,pikeBadAClose,pikeBadBClose,pikeBadSPClose,pikeBadSAClose,pikeBadSBClose,pikeBadSClose,pikeBadSPAClose,pikeBadSBAClose +syn match pikeBadPClose display contained "[}\]]" +syn match pikeBadAClose display contained "[)\]]" +syn match pikeBadBClose display contained "[)}]" +syn match pikeBadSPClose display contained "[;}\]]" +syn match pikeBadSAClose display contained "[;)\]]" +syn match pikeBadSPAClose display contained "[;\]]" +syn match pikeBadSBAClose display contained "[;}]" +syn match pikeBadSClose display contained "[;)}\]]" +syn region pikeNest transparent start="(\@1)" contains=@pikeStmt,pikeBadSPClose keepend + +" It's easy to accidentally add a space after a backslash that was intended +" for line continuation. Some compilers allow it, which makes it +" unpredictable and should be avoided. +syn match pikeBadContinuation contained "\\\s\+$" + +" pikeCommentGroup allows adding matches for special things in comments +syn cluster pikeCommentGroup contains=pikeTodo,pikeBadContinuation " String and Character constants " Highlight special characters (those which have a backslash) differently -syn match pikeSpecial contained "\\[0-7][0-7][0-7]\=\|\\." -syn region pikeString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial -syn match pikeCharacter "'[^\\]'" -syn match pikeSpecialCharacter "'\\.'" -syn match pikeSpecialCharacter "'\\[0-7][0-7]'" -syn match pikeSpecialCharacter "'\\[0-7][0-7][0-7]'" - -" Compound data types -syn region pikeCompoundType start='({' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='})' -syn region pikeCompoundType start='(\[' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='\])' -syn region pikeCompoundType start='(<' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='>)' - -"catch errors caused by wrong parenthesis -syn region pikeParen transparent start='([^{[<(]' end=')' contains=ALLBUT,pikeParenError,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField -syn match pikeParenError ")" -syn match pikeInParen contained "[^(][{}][^)]" +syn match pikeSpecial display contained "\\\%(x\x*\|d\d*\|\o\+\|u\x\{4}\|U\x\{8}\|[abefnrtv]\|$\)" + +" ISO C11 or ISO C++ 11 +if !exists("c_no_cformat") + " Highlight % items in strings. + syn match pikeFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjzt]\|ll\|hh\)\=\%([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained + syn match pikeFormat display "%%" contained + syn region pikeString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,pikeFormat,@Spell keepend + syn region pikeMlString start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeFormat,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend +else + syn region pikeString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,@Spell + syn region pikeMlString transparent start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend +endif + +" Use SQL-syntax highlighting in multiline string if it starts with +" a standard SQL keyword +syn case ignore +" FIXME Use explicit newline match to cover up a bug in the regexp engine +" If the kludge is not used, the match will only start unless at least a space +" follows the initial doublequote on the first line (or the keyword is on +" the first line). +syn region pikeEmbeddedString contained start=+\%(#"\n\?\)\@2<=\_s*\%(SELECT\|INSERT\|UPDATE\|DELETE\|WITH\|CREATE\|DROP\|ALTER\)\>+ skip=+\\\\\|\\"+ end=+[\\#]\@1" +syn match pikeNumbers display transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctalError,pikeOctal +" Same, but without octal error (for comments) +syn match pikeNumbersCom display contained transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctal +syn match pikeNumber display contained "\<\d\+\%(u\=l\{0,2}\|ll\=u\)\>" +"hex number +syn match pikeNumber display contained "\<0x\x\+\%(u\=l\{0,2}\|ll\=u\)\>" +" Flag the first zero of an octal number as something special +syn match pikeOctal display contained "\<0\o\+\%(u\=l\{0,2}\|ll\=u\)\>" contains=pikeOctalZero +syn match pikeOctalZero display contained "\<0" "floating point number, with dot, optional exponent -syn match pikeFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" +syn match pikeFloat display contained "\<\d\+\%(f\|\.[0-9.]\@!\d*\%(e[-+]\=\d\+\)\=[fl]\=\)" "floating point number, starting with a dot, optional exponent -syn match pikeFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" +syn match pikeFloat display contained "[0-9.]\@1" "floating point number, without dot, with exponent -syn match pikeFloat "\<\d\+e[-+]\=\d\+[fl]\=\>" -"hex number -syn match pikeNumber "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>" -"syn match pikeIdentifier "\<[a-z_][a-z0-9_]*\>" -syn case match +syn match pikeFloat display contained "\<\d\+e[-+]\=\d\+[fl]\=\>" + +"hexadecimal floating point number, two variants, with exponent +syn match pikeFloat display contained "\<0x\%(\x\+\.\?\|\x*\.\x\+\)p[-+]\=\d\+[fl]\=\>" + " flag an octal number with wrong digits -syn match pikeOctalError "\<0[0-7]*[89]" +syn match pikeOctalError display contained "\<0\o*[89]\d*" +syn case match if exists("c_comment_strings") " A comment can contain pikeString, pikeCharacter and pikeNumber. @@ -61,82 +186,201 @@ if exists("c_comment_strings") " need to use a special type of pikeString: pikeCommentString, which also ends on " "*/", and sees a "*" at the start of the line as comment again. " Unfortunately this doesn't very well work for // type of comments :-( - syntax match pikeCommentSkip contained "^\s*\*\($\|\s\+\)" - syntax region pikeCommentString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=pikeSpecial,pikeCommentSkip - syntax region pikeComment2String contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=pikeSpecial - syntax region pikeComment start="/\*" end="\*/" contains=pikeTodo,pikeCommentString,pikeCharacter,pikeNumber,pikeFloat - syntax match pikeComment "//.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber - syntax match pikeComment "#\!.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber + syn match pikeCommentSkip contained "^\s*\*\%($\|\s\+\)" + syn region pikeCommentString contained start=+\\\@\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=pikeComment,pikeString,pikeCharacter,pikeNumber,pikeCommentError -syn region pikeIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+ -syn match pikeIncluded contained "<[^>]*>" -syn match pikeInclude "^\s*#\s*include\>\s*["<]" contains=pikeIncluded -"syn match pikeLineSkip "\\$" -syn region pikeDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen -syn region pikePreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen +" These should actually only be parsed in preprocessor conditionals +syn keyword pikeCppOperator contained defined constant efun _Pragma + +syn keyword pikeBoolean true false + +syn match pikeCppPrefix display "^\s*\zs#\s*[a-z]\+" contained +syn region pikePreCondit start="^\s*#\s*\%(if\%(n\?def\)\?\|el\%(se\)\?if\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix +syn match pikePreConditMatch display "^\s*\zs#\s*\%(else\|endif\)\>" +if !exists("c_no_if0") + syn cluster pikeCppOutInGroup contains=pikeCppInIf,pikeCppInElse,pikeCppInElse2,pikeCppOutIf,pikeCppOutIf2,pikeCppOutElse,pikeCppInSkip,pikeCppOutSkip + syn region pikeCppOutWrapper start="^\s*\zs#\s*if\s\+0\+\s*\%($\|//\|/\*\|&\)" end=".\@=\|$" contains=pikeCppOutIf,pikeCppOutElse,@NoSpell fold + syn region pikeCppOutIf contained start="0\+" matchgroup=pikeCppOutWrapper end="^\s*#\s*endif\>" contains=pikeCppOutIf2,pikeCppOutElse + if !exists("c_no_if0_fold") + syn region pikeCppOutIf2 contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell fold + else + syn region pikeCppOutIf2 contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell + endif + syn region pikeCppOutElse contained matchgroup=pikeCppOutWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit + syn region pikeCppInWrapper start="^\s*\zs#\s*if\s\+0*[1-9]\d*\s*\%($\|//\|/\*\||\)" end=".\@=\|$" contains=pikeCppInIf,pikeCppInElse fold + syn region pikeCppInIf contained matchgroup=pikeCppInWrapper start="\d\+" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit + if !exists("c_no_if0_fold") + syn region pikeCppInElse contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2 fold + else + syn region pikeCppInElse contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2 + endif + syn region pikeCppInElse2 contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)\%([^/]\|/[^/*]\)*" end="^\ze\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip,@Spell + syn region pikeCppOutSkip contained start="^\s*#\s*if\%(n\?def\)\?\>" skip="\\$" end="^\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip + syn region pikeCppInSkip contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(if\s\+\%(\d\+\s*\%($\|//\|/\*\||\|&\)\)\@!\|ifn\?def\>\)" skip="\\$" end="^\s*#\s*endif\>" containedin=pikeCppOutElse,pikeCppInIf,pikeCppInSkip contains=TOP,pikePreProc +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,pikeCppOutWrapper,pikeCppInWrapper,@pikeCppOutInGroup,pikeFormat,pikeMlString,pikeCommentStartError,@pikeBadGroup,pikeWord +syn region pikeDefine start="^\s*\zs#\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=@pikeStmt,@pikeBadGroup +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 "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@pikeAutodoc containedin=pikeComment,pikeCommentL +syn cluster pikeCommentGroup add=pikeAutodocReal +syn cluster pikePreProcGroup add=pikeAutodocReal " Highlight User Labels -syn region pikeMulti transparent start='?' end=':' contains=ALLBUT,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' -syn match pikeUserLabel "^\s*\I\i*\s*:$" -syn match pikeUserLabel ";\s*\I\i*\s*:$"ms=s+1 -syn match pikeUserLabel "^\s*\I\i*\s*:[^:]"me=e-1 -syn match pikeUserLabel ";\s*\I\i*\s*:[^:]"ms=s+1,me=e-1 +syn match pikeUserLabel display "\%(^\|[{};]\)\zs\I\i*\s*\ze:\%([^:]\|$\)" contained contains=NONE +syn match pikeUserLabel display "\%(\<\%(break\|continue\)\_s\+\)\@10<=\I\i*" contained contains=NONE +syn match pikeUserLabel display "\%(\