Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
cweb.vim69 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:	CWEB3" Maintainer:	Andreas Scherer <andreas.scherer@pobox.com>4" Last Change:	2011 Dec 25 by Thilo Six5 6" Details of the CWEB language can be found in the article by Donald E. Knuth7" and Silvio Levy, "The CWEB System of Structured Documentation", included as8" file "cwebman.tex" in the standard CWEB distribution, available for9" anonymous ftp at ftp://labrea.stanford.edu/pub/cweb/.10 11" TODO: Section names and C/C++ comments should be treated as TeX material.12" TODO: The current version switches syntax highlighting off for section13" TODO: names, and leaves C/C++ comments as such. (On the other hand,14" TODO: switching to TeX mode in C/C++ comments might be colour overkill.)15 16" quit when a syntax file was already loaded17if exists("b:current_syntax")18  finish19endif20 21" For starters, read the TeX syntax; TeX syntax items are allowed at the top22" level in the CWEB syntax, e.g., in the preamble.  In general, a CWEB source23" code can be seen as a normal TeX document with some C/C++ material24" interspersed in certain defined regions.25runtime! syntax/tex.vim26unlet b:current_syntax27 28" Read the C/C++ syntax too; C/C++ syntax items are treated as such in the29" C/C++ section of a CWEB chunk or in inner C/C++ context in "|...|" groups.30syntax include @webIncludedC <sfile>:p:h/cpp.vim31 32let s:cpo_save = &cpo33set cpo&vim34 35" Inner C/C++ context (ICC) should be quite simple as it's comprised of36" material in "|...|"; however the naive definition for this region would37" hickup at the innocious "\|" TeX macro.  Note: For the time being we expect38" that an ICC begins either at the start of a line or after some white space.39syntax region webInnerCcontext start="\(^\|[ \t\~`(]\)|" end="|" contains=@webIncludedC,webSectionName,webRestrictedTeX,webIgnoredStuff40 41" Genuine C/C++ material.  This syntactic region covers both the definition42" part and the C/C++ part of a CWEB section; it is ended by the TeX part of43" the next section.44syntax region webCpart start="@[dfscp<(]" end="@[ \*]" contains=@webIncludedC,webSectionName,webRestrictedTeX,webIgnoredStuff45 46" Section names contain C/C++ material only in inner context.47syntax region webSectionName start="@[<(]" end="@>" contains=webInnerCcontext contained48 49" The contents of "control texts" is not treated as TeX material, because in50" non-trivial cases this completely clobbers the syntax recognition.  Instead,51" we highlight these elements as "strings".52syntax region webRestrictedTeX start="@[\^\.:t=q]" end="@>" oneline53 54" Double-@ means single-@, anywhere in the CWEB source.  (This allows e-mail55" address <someone@@fsf.org> without going into C/C++ mode.)56syntax match webIgnoredStuff "@@"57 58" Define the default highlighting.59" Only when an item doesn't have highlighting yet60 61hi def link webRestrictedTeX String62 63 64let b:current_syntax = "cweb"65 66let &cpo = s:cpo_save67unlet s:cpo_save68" vim: ts=869 
codekingpro/portable-devtools · Team Ai