Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
typst.vim480 linesDownload Raw Back to syntax
1" Vim syntax file2" Previous Maintainer:  Luca Saccarola <github.e41mv@aleeas.com>3" Maintainer:  This runtime file is looking for a new maintainer.4" Language:    Typst5" Based On:    https://github.com/kaarmu/typst.vim6" Last Change: 2025 Aug 057 8if exists('b:current_syntax')9    finish10endif11 12let s:cpo_save = &cpo13set cpo&vim14 15syntax sync fromstart16syntax spell toplevel17 18" Common {{{119syntax cluster typstCommon20    \ contains=@typstComment21 22" Common > Comment {{{223syntax cluster typstComment24    \ contains=typstCommentBlock,typstCommentLine25syntax region typstCommentBlock26    \ start="/\*" end="\*/" keepend27    \ contains=typstCommentTodo,@Spell28syntax match typstCommentLine29    \ #//.*#30    \ contains=typstCommentTodo,@Spell31syntax keyword typstCommentTodo32    \ contained33    \ TODO FIXME XXX TBD34 35 36" Code {{{137syntax cluster typstCode38    \ contains=@typstCommon39            \ ,@typstCodeKeywords40            \ ,@typstCodeConstants41            \ ,@typstCodeIdentifiers42            \ ,@typstCodeFunctions43            \ ,@typstCodeParens44 45" Code > Keywords {{{246syntax cluster typstCodeKeywords47    \ contains=typstCodeConditional48            \ ,typstCodeRepeat49            \ ,typstCodeKeyword50            \ ,typstCodeStatement51syntax keyword typstCodeConditional52    \ contained53    \ if else54syntax keyword typstCodeRepeat55    \ contained56    \ while for57syntax keyword typstCodeKeyword58    \ contained59    \ not in and or return60syntax region typstCodeStatement61    \ contained62    \ matchgroup=typstCodeStatementWord start=/\v(let|set|import|include)>/63    \ matchgroup=Noise end=/\v%(;|$)/64    \ contains=@typstCode65syntax region typstCodeStatement66    \ contained67    \ matchgroup=typstCodeStatementWord start=/show/68    \ matchgroup=Noise end=/\v%(:|$)/ keepend69    \ contains=@typstCode70    \ skipwhite nextgroup=@typstCode,typstCodeShowRocket71syntax match typstCodeShowRocket72    \ contained73    \ /.*=>/74    \ contains=@typstCode75    \ skipwhite nextgroup=@typstCode76 77" Code > Identifiers {{{278syntax cluster typstCodeIdentifiers79    \ contains=typstCodeIdentifier80            \ ,typstCodeFieldAccess81syntax match typstCodeIdentifier82    \ contained83    \ /\v\w\k*>(<%(let|set|show|import|include))@<![\.\[\(]@!/84syntax match typstCodeFieldAccess85    \ contained86    \ /\v\w\k*>(<%(let|set|show|import|include))@<!\.[\[\(]@!/87    \ nextgroup=typstCodeFieldAccess,typstCodeFunction88 89" Code > Functions {{{290syntax cluster typstCodeFunctions91    \ contains=typstCodeFunction92syntax match typstCodeFunction93    \ contained94    \ /\v\w\k*>(<%(let|set|show|import|include))@<![\(\[]@=/95    \ nextgroup=typstCodeFunctionArgument96syntax match typstCodeFunctionArgument97    \ contained98    \ /\v%(%(\(.{-}\)|\[.{-}\]|\{.{-}\}))*/ transparent99    \ contains=@typstCode100 101" Code > Constants {{{2102syntax cluster typstCodeConstants103    \ contains=typstCodeConstant104            \ ,typstCodeNumberInteger105            \ ,typstCodeNumberFloat106            \ ,typstCodeNumberLength107            \ ,typstCodeNumberAngle108            \ ,typstCodeNumberRatio109            \ ,typstCodeNumberFraction110            \ ,typstCodeString111            \ ,typstCodeLabel112syntax match typstCodeConstant113    \ contained114    \ /\v<%(none|auto|true|false)-@!>/115syntax match typstCodeNumberInteger116    \ contained117    \ /\v<\d+>/118 119syntax match typstCodeNumberFloat120    \ contained121    \ /\v<\d+\.\d*>/122syntax match typstCodeNumberLength123    \ contained124    \ /\v<\d+(\.\d*)?(pt|mm|cm|in|em)>/125syntax match typstCodeNumberAngle126    \ contained127    \ /\v<\d+(\.\d*)?(deg|rad)>/128syntax match typstCodeNumberRatio129    \ contained130    \ /\v<\d+(\.\d*)?\%/131syntax match typstCodeNumberFraction132    \ contained133    \ /\v<\d+(\.\d*)?fr>/134syntax region typstCodeString135    \ contained136    \ start=/"/ skip=/\v\\\\|\\"/ end=/"/137    \ contains=@Spell138syntax match typstCodeLabel139    \ contained140    \ /\v\<\K%(\k*-*)*\>/141 142" Code > Parens {{{2143syntax cluster typstCodeParens144    \ contains=typstCodeParen145            \ ,typstCodeBrace146            \ ,typstCodeBracket147            \ ,typstCodeDollar148            \ ,typstMarkupRawInline149            \ ,typstMarkupRawBlock150syntax region typstCodeParen151    \ contained152    \ matchgroup=Noise start=/(/ end=/)/153    \ contains=@typstCode154syntax region typstCodeBrace155    \ contained156    \ matchgroup=Noise start=/{/ end=/}/157    \ contains=@typstCode158syntax region typstCodeBracket159    \ contained160    \ matchgroup=Noise start=/\[/ end=/\]/161    \ contains=@typstMarkup162syntax region typstCodeDollar163    \ contained164    \ matchgroup=Number start=/\\\@<!\$/ end=/\\\@<!\$/165    \ contains=@typstMath166 167 168" Hashtag {{{1169syntax cluster typstHashtag170    \ contains=@typstHashtagKeywords171            \ ,@typstHashtagConstants172            \ ,@typstHashtagIdentifiers173            \ ,@typstHashtagFunctions174            \ ,@typstHashtagParens175 176" Hashtag > Keywords {{{2177syntax cluster typstHashtagKeywords178    \ contains=typstHashtagConditional179            \ ,typstHashtagRepeat180            \ ,typstHashtagKeywords181            \ ,typstHashtagStatement182 183" syntax match typstHashtagControlFlowError184"     \ /\v#%(if|while|for)>-@!.{-}$\_.{-}%(\{|\[|\()/185syntax match typstHashtagControlFlow186    \ /\v#%(if|while|for)>.{-}\ze%(\{|\[|\()/187    \ contains=typstHashtagConditional,typstHashtagRepeat188    \ nextgroup=@typstCode189syntax region typstHashtagConditional190    \ contained191    \ start=/\v#if>/ end=/\v\ze(\{|\[)/192    \ contains=@typstCode193syntax region typstHashtagRepeat194    \ contained195    \ start=/\v#(while|for)>/ end=/\v\ze(\{|\[)/196    \ contains=@typstCode197syntax match typstHashtagKeyword198    \ /\v#(return)>/199    \ skipwhite nextgroup=@typstCode200syntax region typstHashtagStatement201    \ matchgroup=typstHashtagStatementWord start=/\v#(let|set|import|include)>/202    \ matchgroup=Noise end=/\v%(;|$)/203    \ contains=@typstCode204syntax region typstHashtagStatement205    \ matchgroup=typstHashtagStatementWord start=/#show/206    \ matchgroup=Noise end=/\v%(:|$)/ keepend207    \ contains=@typstCode208    \ skipwhite nextgroup=@typstCode,typstCodeShowRocket209 210" Hashtag > Constants {{{2211syntax cluster typstHashtagConstants212    \ contains=typstHashtagConstant213syntax match typstHashtagConstant214    \ /\v#(none|auto|true|false)>/215 216" Hashtag > Identifiers {{{2217syntax cluster typstHashtagIdentifiers218    \ contains=typstHashtagIdentifier219            \ ,typstHashtagFieldAccess220syntax match typstHashtagIdentifier221    \ /\v#\w\k*>(<%(let|set|show|import|include))@<![\.\[\(]@!/222syntax match typstHashtagFieldAccess223    \ /\v#\w\k*>(<%(let|set|show|import|include))@<!\.[\[\(]@!/224    \ nextgroup=typstCodeFieldAccess,typstCodeFunction225 226" Hashtag > Functions {{{2227syntax cluster typstHashtagFunctions228    \ contains=typstHashtagFunction229syntax match typstHashtagFunction230    \ /\v#\w\k*>(<%(let|set|show|import|include))@<![\(\[]@=/231    \ nextgroup=typstCodeFunctionArgument232 233" Hashtag > Parens {{{2234syntax cluster typstHashtagParens235    \ contains=typstHashtagParen236            \ ,typstHashtagBrace237            \ ,typstHashtagBracket238            \ ,typstHashtagDollar239syntax region typstHashtagParen240    \ matchgroup=Noise start=/#(/ end=/)/241    \ contains=@typstCode242syntax region typstHashtagBrace243    \ matchgroup=Noise start=/#{/ end=/}/244    \ contains=@typstCode245syntax region typstHashtagBracket246    \ matchgroup=Noise start=/#\[/ end=/\]/247    \ contains=@typstMarkup248syntax region typstHashtagDollar249    \ matchgroup=Noise start=/#\$/ end=/\\\@<!\$/250    \ contains=@typstMath251 252 253" Markup {{{1254syntax cluster typstMarkup255    \ contains=@typstCommon256            \ ,@Spell257            \ ,@typstHashtag258            \ ,@typstMarkupText259            \ ,@typstMarkupParens260 261" Markup > Text {{{2262syntax cluster typstMarkupText263    \ contains=typstMarkupRawInline264            \ ,typstMarkupRawBlock265            \ ,typstMarkupLabel266            \ ,typstMarkupReference267            \ ,typstMarkupUrl268            \ ,typstMarkupHeading269            \ ,typstMarkupBulletList270            \ ,typstMarkupEnumList271            \ ,typstMarkupTermList272            \ ,typstMarkupBold273            \ ,typstMarkupItalic274            \ ,typstMarkupLinebreak275            \ ,typstMarkupNonbreakingSpace276            \ ,typstMarkupShy277            \ ,typstMarkupDash278            \ ,typstMarkupEllipsis279 280" Raw Text281syntax match typstMarkupRawInline282    \ /`.\{-}`/283syntax region typstMarkupRawBlock284    \ matchgroup=Macro start=/```\w*/285    \ matchgroup=Macro end=/```/ keepend286syntax region typstMarkupCodeBlockTypst287    \ matchgroup=Macro start=/```typst/288    \ matchgroup=Macro end=/```/ contains=@typstCode keepend289    \ concealends290 291for s:name in get(g:, 'typst_embedded_languages', [])292    let s:include = ['syntax include'293                \   ,'@typstEmbedded_'..s:name294                \   ,'syntax/'..s:name..'.vim']295    let s:rule = ['syn region'296                \,s:name297                \,'matchgroup=Macro'298                \,'start=/```'..s:name..'\>/ end=/```/' 299                \,'contains=@typstEmbedded_'..s:name 300                \,'keepend'301                \,'concealends']302    execute 'silent! ' .. join(s:include, ' ')303    unlet! b:current_syntax304    execute join(s:rule, ' ')305endfor306 307" Label & Reference308syntax match typstMarkupLabel309    \ /\v\<\K%(\k*-*)*\>/310syntax match typstMarkupReference311    \ /\v\@\K%(\k*-*)*/312 313" URL314syntax match typstMarkupUrl315    \ #\v\w+://\S*#316 317" Heading318syntax match typstMarkupHeading319    \ /^\s*\zs=\{1,6}\s.*$/320    \ contains=typstMarkupLabel,@Spell321 322" Lists323syntax match typstMarkupBulletList324    \ /\v^\s*-\s+/325syntax match typstMarkupEnumList326    \ /\v^\s*(\+|\d+\.)\s+/327syntax region typstMarkupTermList328    \ oneline start=/\v^\s*\/\s/ end=/:/329    \ contains=@typstMarkup330 331" Bold & Italic332syntax match typstMarkupBold333    \ /\v(\w|\\)@1<!\*\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!\*/334    \ contains=typstMarkupBoldRegion335syntax match typstMarkupItalic336    \ /\v(\w|\\)@1<!_\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!_/337    \ contains=typstMarkupItalicRegion338syntax match typstMarkupBoldItalic339    \ contained340    \ /\v(\w|\\)@1<![_\*]\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!\2/341    \ contains=typstMarkupBoldRegion,typstMarkupItalicRegion342syntax region typstMarkupBoldRegion343    \ contained344    \ transparent matchgroup=typstMarkupBold345    \ start=/\(^\|[^0-9a-zA-Z]\)\@<=\*/ end=/\*\($\|[^0-9a-zA-Z]\)\@=/346    \ concealends contains=typstMarkupBoldItalic,typstMarkupLabel,@Spell347syntax region typstMarkupItalicRegion348    \ contained349    \ transparent matchgroup=typstMarkupItalic350    \ start=/\(^\|[^0-9a-zA-Z]\)\@<=_/ end=/_\($\|[^0-9a-zA-Z]\)\@=/351    \ concealends contains=typstMarkupBoldItalic,typstMarkupLabel,@Spell352 353" Linebreak & Special Whitespace354syntax match typstMarkupLinebreak355    \ /\\\\/356syntax match typstMarkupNonbreakingSpace357    \ /\~/358syntax match typstMarkupShy359    \ /-?/360 361" Special Symbols362syntax match typstMarkupDash363    \ /-\{2,3}/364syntax match typstMarkupEllipsis365    \ /\.\.\./366 367" Markup > Parens {{{2368syntax cluster typstMarkupParens369    \ contains=typstMarkupBracket370            \ ,typstMarkupDollar371syntax region typstMarkupBracket372    \ matchgroup=Noise start=/\[/ end=/\]/373    \ contains=@typstMarkup374syntax region typstMarkupDollar375    \ matchgroup=Special start=/\\\@<!\$/ end=/\\\@<!\$/376    \ contains=@typstMath377 378 379" Math {{{1380syntax cluster typstMath381    \ contains=@typstCommon382            \ ,@typstHashtag383            \ ,typstMathIdentifier384            \ ,typstMathFunction385            \ ,typstMathNumber386            \ ,typstMathSymbol387            \ ,typstMathBold388            \ ,typstMathScripts389            \ ,typstMathQuote390 391syntax match typstMathIdentifier392    \ /\a\a\+/393    \ contained394syntax match typstMathFunction395    \ /\a\a\+\ze(/396    \ contained397syntax match typstMathNumber398    \ /\<\d\+\>/399    \ contained400syntax region typstMathQuote401    \ matchgroup=String start=/"/ skip=/\\"/ end=/"/402    \ contained403 404" Math > Linked groups {{{2405highlight default link typstMathIdentifier          Identifier406highlight default link typstMathFunction            Statement407highlight default link typstMathNumber              Number408highlight default link typstMathSymbol              Statement409 410" Highlighting {{{1411 412" Highlighting > Linked groups {{{2413highlight default link typstCommentBlock            Comment414highlight default link typstCommentLine             Comment415highlight default link typstCommentTodo             Todo416highlight default link typstCodeConditional         Conditional417highlight default link typstCodeRepeat              Repeat418highlight default link typstCodeKeyword             Keyword419highlight default link typstCodeConstant            Constant420highlight default link typstCodeNumberInteger       Number421highlight default link typstCodeNumberFloat         Number422highlight default link typstCodeNumberLength        Number423highlight default link typstCodeNumberAngle         Number424highlight default link typstCodeNumberRatio         Number425highlight default link typstCodeNumberFraction      Number426highlight default link typstCodeString              String427highlight default link typstCodeLabel               Structure428highlight default link typstCodeStatementWord       Statement429highlight default link typstCodeIdentifier          Identifier430highlight default link typstCodeFieldAccess         Identifier431highlight default link typstCodeFunction            Function432highlight default link typstCodeParen               Noise433highlight default link typstCodeBrace               Noise434highlight default link typstCodeBracket             Noise435highlight default link typstCodeDollar              Noise436" highlight default link typstHashtagControlFlowError Error437highlight default link typstHashtagConditional      Conditional438highlight default link typstHashtagRepeat           Repeat439highlight default link typstHashtagKeyword          Keyword440highlight default link typstHashtagConstant         Constant441highlight default link typstHashtagStatementWord    Statement442highlight default link typstHashtagIdentifier       Identifier443highlight default link typstHashtagFieldAccess      Identifier444highlight default link typstHashtagFunction         Function445highlight default link typstHashtagParen            Noise446highlight default link typstHashtagBrace            Noise447highlight default link typstHashtagBracket          Noise448highlight default link typstHashtagDollar           Noise449highlight default link typstMarkupRawInline         Macro450highlight default link typstMarkupRawBlock          Macro451highlight default link typstMarkupLabel             Structure452highlight default link typstMarkupReference         Structure453highlight default link typstMarkupBulletList        Structure454" highlight default link typstMarkupItalicError       Error455" highlight default link typstMarkupBoldError         Error456highlight default link typstMarkupEnumList          Structure457highlight default link typstMarkupLinebreak         Structure458highlight default link typstMarkupNonbreakingSpace  Structure459highlight default link typstMarkupShy               Structure460highlight default link typstMarkupDash              Structure461highlight default link typstMarkupEllipsis          Structure462highlight default link typstMarkupTermList          Structure463highlight default link typstMarkupDollar            Noise464 465" Highlighting > Custom Styling {{{2466highlight! Conceal ctermfg=NONE ctermbg=NONE guifg=NONE guibg=NONE467 468highlight default typstMarkupHeading                    term=underline,bold     cterm=underline,bold    gui=underline,bold469highlight default typstMarkupUrl                        term=underline          cterm=underline         gui=underline470highlight default typstMarkupBold                       term=bold               cterm=bold              gui=bold471highlight default typstMarkupItalic                     term=italic             cterm=italic            gui=italic472highlight default typstMarkupBoldItalic                 term=bold,italic        cterm=bold,italic       gui=bold,italic473 474let b:current_syntax = 'typst'475 476let &cpo = s:cpo_save477unlet s:cpo_save478 479" }}}1480 
codekingpro/portable-devtools · Team Ai