diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:09:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:09:20 +0000 |
commit | 029f72b1a93430b24b88eb3a72c6114d9f149737 (patch) | |
tree | 765d5c2041967f9c6fef195fe343d9234a030e90 /runtime/syntax/gift.vim | |
parent | Initial commit. (diff) | |
download | vim-029f72b1a93430b24b88eb3a72c6114d9f149737.tar.xz vim-029f72b1a93430b24b88eb3a72c6114d9f149737.zip |
Adding upstream version 2:9.1.0016.upstream/2%9.1.0016
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/syntax/gift.vim')
-rw-r--r-- | runtime/syntax/gift.vim | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/runtime/syntax/gift.vim b/runtime/syntax/gift.vim new file mode 100644 index 0000000..3f8d631 --- /dev/null +++ b/runtime/syntax/gift.vim @@ -0,0 +1,216 @@ +" Vim syntax file +" +" Language: Moodle GIFT (General Import Format Template) +" Maintainer: Selim Temizer (http://selimtemizer.com) +" Creation: November 28, 2020 +" Latest Revision: December 21, 2020 +" Note: The order of entities in this file is important! + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + + +setlocal conceallevel=1 + +"----------------------------------------------- +" GIFT entities + +syn match giftS "\~" contained "GIFT special characters +syn match giftS "=" contained +syn match giftS "#" contained +syn match giftS "{" contained +syn match giftS "}" contained +syn match giftS ":" contained + +syn match giftES "\\\~" contained conceal cchar=~ "GIFT escaped special characters +syn match giftES "\\=" contained conceal cchar== +syn match giftES "\\#" contained conceal cchar=# +syn match giftES "\\{" contained conceal cchar={ +syn match giftES "\\}" contained conceal cchar=} +syn match giftES "\\:" contained conceal cchar=: + +syn match giftEN "\\n" contained conceal cchar=n "GIFT escaped newline + +syn match giftFormat "\[html]" contained "GIFT formats +syn match giftFormat "\[plain]" contained +syn match giftFormat "\[moodle]" contained +syn match giftFormat "\[markdown]" contained + +"-------------------------------------------------------- +" HTML entities + +syn match giftH "<" contained "HTML characters that might need to be handled/escaped +syn match giftH ">" contained +syn match giftH "&" contained + +syn match giftEH "<" contained conceal cchar=< "HTML escaped characters +syn match giftEH ">" contained conceal cchar=> +syn match giftEH "&" contained conceal cchar=& +syn match giftEH " " contained conceal cchar=_ + +"------------------------------------------------------- +" Answer components: Feedback and general feedback + +syn match giftFB "#\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|#\|####\|}\)" contained contains=giftF "Feedback block +syn match giftF "#\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|#\|####\|}\)" contained contains=@giftCEF "Feedback + +syn match giftGFB "####\_.\{-}\(\_^\|[^\\]\)\ze}" contained contains=giftGF "General feedback block +syn match giftGF "####\zs\_.\{-}\(\_^\|[^\\]\)\ze}" contained contains=@giftCEF "General feedback + +"------------------------------------------------------ +" Answer components: Other components + +syn keyword giftTF T TRUE F FALSE contained + +syn match giftNum1 "[-+]\=[.0-9]\+" contained "Something matching a number + +syn match giftNum2 "[-+]\=[.0-9]\+\s*:\s*[-+]\=[.0-9]\+" contained contains=giftNum2D "Number with error margin +syn match giftNum2D ":" contained "Associated delimiter + +syn match giftNum3 "[-+]\=[.0-9]\+\s*\.\.\s*[-+]\=[.0-9]\+" contained contains=giftNum3D "Number as min/max range +syn match giftNum3D "\.\." contained "Associated delimiter + +syn match giftWeightB "%-*[0-9]\{1,2}\.\?[0-9]*%" contained contains=giftWeight "Weight block +syn match giftWeight "%\zs-*[0-9]\{1,2}\.\?[0-9]*\ze%" contained "Weight + +"----------------------------------------------------- +" Answer choices + +syn match giftWrongNum "\~\zs\_.\{-}\(\_^\|[^\\]\)\ze\(####\|}\)" contained contains=@giftCEFF "Wrong numeric choice +syn match giftRightNum "=\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCEFFW,@giftNums "Right numeric choice + +syn match giftWrong "\~\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCEFFW "Wrong choice +syn match giftRight "=\zs\_.\{-}\(\ze->\|\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)\)" contained contains=@giftCEFFW "Right choice +syn match giftMatchB "->\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=giftMatch "Match choice block +syn match giftMatch "->\zs\_.\{-}\(\_^\|[^\\]\)\ze\(=\|\~\|####\|}\)" contained contains=@giftCE "Match choice + +"---------------------------------------------------- +" Answer + +syn match giftAnswer "{\_.\{-}\(\_^\|[^\\]\)}" contained keepend contains=@giftA "General answer +syn match giftAnswer "{}" contained "Minimal answer + +syn match giftAnswerNum "{\_[[:space:]]*#\_[^#]\_.\{-}\(\_^\|[^\\]\)}" contained keepend contains=@giftANum "Numeric answer +syn match giftAnswerNumD "{\zs\_[[:space:]]*#" contained "Associated delimiter + +"--------------------------------------------------- +" Question + +" The first pattern matches the last question at the end of the file (in case there is no empty line coming after). +" However, it slows down parsing (and especially scrolling up), therefore it is commented out. + +"syn match giftQuestion "[^{[:space:]]\_.\{-}\%$" keepend contains=@giftCEF,giftAnswer,giftAnswerNum + syn match giftQuestion "[^{[:space:]]\_.\{-}\n\(\s*\n\)\+" keepend contains=@giftCEF,giftAnswer,giftAnswerNum + +"-------------------------------------------------- +" Question name + +syn match giftName "::\_.\{-}::" contains=@giftCE,giftNameD "Question name +syn match giftNameD "::" contained "Associated delimiter + +"------------------------------------------------- +" Category + +syn match giftCategoryB "^\s*\$CATEGORY:.*\n\+" contains=giftCategory "Category block +syn match giftCategory "^\s*\$CATEGORY:\zs.*\ze\n" contained "Category + +"------------------------------------------------ +" Comments (may need to be the last entity) + +syn keyword giftTodo FIXME TODO NOTE FIX XXX contained + +syn match giftIdB "\[id:\(\\]\|[^][:cntrl:]]\)\+]" contained contains=giftId "Id block +syn match giftId "\[id:\zs\(\\]\|[^][:cntrl:]]\)\+\ze]" contained "Id + +syn match giftTagB "\[tag:\(\\]\|[^]<>`[:cntrl:]]\)\+]" contained contains=giftTag "Tag block +syn match giftTag "\[tag:\zs\(\\]\|[^]<>`[:cntrl:]]\)\+\ze]" contained "Tag + +syn match giftComment "^\s*//.*" contains=giftTodo,giftIdB,giftTagB + +"----------------------------------------------- +" Clusters + +"Comments and entities (to be escaped) +syn cluster giftCE contains=giftComment,giftS,giftES,giftEN,giftH,giftEH + +"The above plus format +syn cluster giftCEF contains=@giftCE,giftFormat + +"The above plus feedback block +syn cluster giftCEFF contains=@giftCEF,giftFB + +"The above plus weight block +syn cluster giftCEFFW contains=@giftCEFF,giftWeightB + +"Possible numerical representations +syn cluster giftNums contains=giftNum1,giftNum2,giftNum3 + +"Possible contents of answers +syn cluster giftA contains=giftComment,giftTF,giftWrong,giftRight,giftMatchB,giftFB,giftGFB + +"Possible contents of numerical answers +syn cluster giftANum contains=giftAnswerNumD,giftComment,@giftNums,giftWrongNum,giftRightNum,giftFB,giftGFB + +"----------------------------------------------- + +let b:current_syntax = "gift" + +"----------------------------------------------- + +hi Conceal ctermbg=NONE ctermfg=Blue guibg=NONE guifg=Blue +hi Feedback ctermbg=NONE ctermfg=DarkCyan guibg=NONE guifg=DarkCyan +hi GFeedback ctermbg=NONE ctermfg=DarkGreen guibg=NONE guifg=DarkGreen +hi WeightB ctermbg=NONE ctermfg=DarkYellow guibg=NONE guifg=DarkYellow + +"----------------------------------------------- + +hi def link giftS Error +hi def link giftES Conceal +hi def link giftEN Conceal +hi def link giftFormat LineNr + +hi def link giftH Error +hi def link giftEH Conceal + +hi def link giftFB PreProc +hi def link giftF Feedback +hi def link giftGFB Title +hi def link giftGF GFeedback + +hi def link giftTF Question +hi def link giftNum1 Question +hi def link giftNum2 Question +hi def link giftNum2D Special +hi def link giftNum3 Question +hi def link giftNum3D Special +hi def link giftWeightB WeightB +hi def link giftWeight Identifier + +hi def link giftWrongNum Constant +hi def link giftRightNum Question +hi def link giftWrong Constant +hi def link giftRight Question +hi def link giftMatchB ModeMsg +hi def link giftMatch Constant + +hi def link giftAnswer MoreMsg +hi def link giftAnswerNum MoreMsg +hi def link giftAnswerNumD Identifier + +hi def link giftQuestion Identifier + +hi def link giftName PreProc +hi def link giftNameD Directory + +hi def link giftCategoryB LineNr +hi def link giftCategory Directory + +hi def link giftTodo Todo +hi def link giftIdB LineNr +hi def link giftId Title +hi def link giftTagB LineNr +hi def link giftTag Constant +hi def link giftComment Comment |