codekingpro/portable-devtools
114k
1" Vim syntax file2"3" Language: Moodle GIFT (General Import Format Template)4" Maintainer: Selim Temizer (http://selimtemizer.com)5" Creation: November 28, 20206" Latest Revision: December 21, 20207" Note: The order of entities in this file is important!8 9if version < 60010 syntax clear11elseif exists("b:current_syntax")12 finish13endif14 15 16setlocal conceallevel=117 18"-----------------------------------------------19" GIFT entities20 21syn match giftS "\~" contained "GIFT special characters22syn match giftS "=" contained23syn match giftS "#" contained24syn match giftS "{" contained25syn match giftS "}" contained26syn match giftS ":" contained27 28syn match giftES "\\\~" contained conceal cchar=~ "GIFT escaped special characters29syn match giftES "\\=" contained conceal cchar==30syn match giftES "\\#" contained conceal cchar=#31syn match giftES "\\{" contained conceal cchar={32syn match giftES "\\}" contained conceal cchar=}33syn match giftES "\\:" contained conceal cchar=:34 35syn match giftEN "\\n" contained conceal cchar=n "GIFT escaped newline36 37syn match giftFormat "\[html]" contained "GIFT formats38syn match giftFormat "\[plain]" contained39syn match giftFormat "\[moodle]" contained40syn match giftFormat "\[markdown]" contained41 42"--------------------------------------------------------43" HTML entities44 45syn match giftH "<" contained "HTML characters that might need to be handled/escaped46syn match giftH ">" contained47syn match giftH "&" contained48 49syn match giftEH "<" contained conceal cchar=< "HTML escaped characters50syn match giftEH ">" contained conceal cchar=>51syn match giftEH "&" contained conceal cchar=&52syn match giftEH " " contained conceal cchar=_53 54"-------------------------------------------------------55" Answer components: Feedback and general feedback56 57syn match giftFB "#\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|#\|####\|}\)" contained contains=giftF "Feedback block58syn match giftF "#\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|#\|####\|}\)" contained contains=@giftCEF "Feedback59 60syn match giftGFB "####\_.\{-}\(\_^\|[^\\]\)\ze}" contained contains=giftGF "General feedback block61syn match giftGF "####\zs\_.\{-}\(\_^\|[^\\]\)\ze}" contained contains=@giftCEF "General feedback62 63"------------------------------------------------------64" Answer components: Other components65 66syn keyword giftTF T TRUE F FALSE contained67 68syn match giftNum1 "[-+]\=[.0-9]\+" contained "Something matching a number69 70syn match giftNum2 "[-+]\=[.0-9]\+\s*:\s*[-+]\=[.0-9]\+" contained contains=giftNum2D "Number with error margin71syn match giftNum2D ":" contained "Associated delimiter72 73syn match giftNum3 "[-+]\=[.0-9]\+\s*\.\.\s*[-+]\=[.0-9]\+" contained contains=giftNum3D "Number as min/max range74syn match giftNum3D "\.\." contained "Associated delimiter75 76syn match giftWeightB "%-*[0-9]\{1,2}\.\?[0-9]*%" contained contains=giftWeight "Weight block77syn match giftWeight "%\zs-*[0-9]\{1,2}\.\?[0-9]*\ze%" contained "Weight78 79"-----------------------------------------------------80" Answer choices81 82syn match giftWrongNum "\~\zs\_.\{-}\(\_^\|[^\\]\)\ze\(####\|}\)" contained contains=@giftCEFF "Wrong numeric choice83syn match giftRightNum "=\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCEFFW,@giftNums "Right numeric choice84 85syn match giftWrong "\~\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCEFFW "Wrong choice86syn match giftRight "=\zs\_.\{-}\(\ze->\|\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)\)" contained contains=@giftCEFFW "Right choice87syn match giftMatchB "->\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=giftMatch "Match choice block88syn match giftMatch "->\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCE "Match choice89 90"----------------------------------------------------91" Answer92 93syn match giftAnswer "{\_.\{-}\(\_^\|[^\\]\)}" contained keepend contains=@giftA "General answer94syn match giftAnswer "{}" contained "Minimal answer95 96syn match giftAnswerNum "{\_[[:space:]]*#\_[^#]\_.\{-}\(\_^\|[^\\]\)}" contained keepend contains=@giftANum "Numeric answer97syn match giftAnswerNumD "{\zs\_[[:space:]]*#" contained "Associated delimiter98 99"---------------------------------------------------100" Question101 102" The first pattern matches the last question at the end of the file (in case there is no empty line coming after).103" However, it slows down parsing (and especially scrolling up), therefore it is commented out.104 105"syn match giftQuestion "[^{[:space:]]\_.\{-}\%$" keepend contains=@giftCEF,giftAnswer,giftAnswerNum106 syn match giftQuestion "[^{[:space:]]\_.\{-}\n\(\s*\n\)\+" keepend contains=@giftCEF,giftAnswer,giftAnswerNum107 108"--------------------------------------------------109" Question name110 111syn match giftName "::\_.\{-}::" contains=@giftCE,giftNameD "Question name112syn match giftNameD "::" contained "Associated delimiter113 114"-------------------------------------------------115" Category116 117syn match giftCategoryB "^\s*\$CATEGORY:.*\n\+" contains=giftCategory "Category block118syn match giftCategory "^\s*\$CATEGORY:\zs.*\ze\n" contained "Category119 120"------------------------------------------------121" Comments (may need to be the last entity)122 123syn keyword giftTodo FIXME TODO NOTE FIX XXX contained124 125syn match giftIdB "\[id:\(\\]\|[^][:cntrl:]]\)\+]" contained contains=giftId "Id block126syn match giftId "\[id:\zs\(\\]\|[^][:cntrl:]]\)\+\ze]" contained "Id127 128syn match giftTagB "\[tag:\(\\]\|[^]<>`[:cntrl:]]\)\+]" contained contains=giftTag "Tag block129syn match giftTag "\[tag:\zs\(\\]\|[^]<>`[:cntrl:]]\)\+\ze]" contained "Tag130 131syn match giftComment "^\s*//.*" contains=giftTodo,giftIdB,giftTagB132 133"-----------------------------------------------134" Clusters135 136"Comments and entities (to be escaped)137syn cluster giftCE contains=giftComment,giftS,giftES,giftEN,giftH,giftEH138 139"The above plus format140syn cluster giftCEF contains=@giftCE,giftFormat141 142"The above plus feedback block143syn cluster giftCEFF contains=@giftCEF,giftFB144 145"The above plus weight block146syn cluster giftCEFFW contains=@giftCEFF,giftWeightB147 148"Possible numerical representations149syn cluster giftNums contains=giftNum1,giftNum2,giftNum3150 151"Possible contents of answers152syn cluster giftA contains=giftComment,giftTF,giftWrong,giftRight,giftMatchB,giftFB,giftGFB153 154"Possible contents of numerical answers155syn cluster giftANum contains=giftAnswerNumD,giftComment,@giftNums,giftWrongNum,giftRightNum,giftFB,giftGFB156 157"-----------------------------------------------158 159let b:current_syntax = "gift"160 161"-----------------------------------------------162 163hi Conceal ctermbg=NONE ctermfg=Blue guibg=NONE guifg=Blue164hi Feedback ctermbg=NONE ctermfg=DarkCyan guibg=NONE guifg=DarkCyan165hi GFeedback ctermbg=NONE ctermfg=DarkGreen guibg=NONE guifg=DarkGreen166hi WeightB ctermbg=NONE ctermfg=DarkYellow guibg=NONE guifg=DarkYellow167 168"-----------------------------------------------169 170hi def link giftS Error171hi def link giftES Conceal172hi def link giftEN Conceal173hi def link giftFormat LineNr174 175hi def link giftH Error176hi def link giftEH Conceal177 178hi def link giftFB PreProc179hi def link giftF Feedback180hi def link giftGFB Title181hi def link giftGF GFeedback182 183hi def link giftTF Question184hi def link giftNum1 Question185hi def link giftNum2 Question186hi def link giftNum2D Special187hi def link giftNum3 Question188hi def link giftNum3D Special189hi def link giftWeightB WeightB190hi def link giftWeight Identifier191 192hi def link giftWrongNum Constant193hi def link giftRightNum Question194hi def link giftWrong Constant195hi def link giftRight Question196hi def link giftMatchB ModeMsg197hi def link giftMatch Constant198 199hi def link giftAnswer MoreMsg200hi def link giftAnswerNum MoreMsg201hi def link giftAnswerNumD Identifier202 203hi def link giftQuestion Identifier204 205hi def link giftName PreProc206hi def link giftNameD Directory207 208hi def link giftCategoryB LineNr209hi def link giftCategory Directory210 211hi def link giftTodo Todo212hi def link giftIdB LineNr213hi def link giftId Title214hi def link giftTagB LineNr215hi def link giftTag Constant216hi def link giftComment Comment217 