Skip to content

Instantly share code, notes, and snippets.

@solyarisoftware
Last active March 31, 2017 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solyarisoftware/f66b292a95e9014b30e8ad6a284aa44e to your computer and use it in GitHub Desktop.
Save solyarisoftware/f66b292a95e9014b30e8ad6a284aa44e to your computer and use it in GitHub Desktop.
ChatScript Vim Syntax Highlight

ChatScript Vim Syntax Highlight

curl -fLo --create-dirs ~/.vim/ftdetect/ChatScript.vim https://gist.githubusercontent.com/solyaris/f66b292a95e9014b30e8ad6a284aa44e/raw/06b7bd0e13bd1fa3b4acc9538c86657cb9ca9270/ftdetect.vim

curl -fLo --create-dirs ~/.vim/syntax/ChatScript.vim https://gist.githubusercontent.com/solyaris/f66b292a95e9014b30e8ad6a284aa44e/raw/06b7bd0e13bd1fa3b4acc9538c86657cb9ca9270/syntax.vim
" ~/.vim/ftdetect/ChatScript.vim
autocmd BufNewFile,BufRead *.top setfiletype ChatScript
" ~/.vim/syntax/ChatScript.vim
" Vim syntax file
" Language: ChatScript
" Maintainer: Giorgio Robino (giorgio.robino@gmail.com)
" Latest Revision: 28 March 2017
" Quit when a syntax file was already loaded.
if exists("b:current_syntax")
finish
endif
"echom "Our syntax highlighting code will go here."
"syntax keyword csKeyword topic concept
"syntax keyword csKeyword t: ?: u: 's:'
syntax match Statement '[rstu?]:'
syntax match Statement '[a-q]:'
syntax match Statement '?:'
syntax match csKeyword 'topic:\|concept:'
" syntax match csKeyword 'concept:'
syntax match csComment '\v#.*$'
syntax match csTestComment '\v#!.*$'
syntax match csLabel '\a\+_\a\+'
syntax match csString '".*"'
syntax match csDelimiter '(\|)\|\[\|\]'
syntax match csMatchVariable '_\(\d*\|\*\)'
syntax match csTopicName '\~\S\+'
syntax match csFunction '\^[a-zA-Z]\+'
" User permanent variables
syntax match csVariable '\$[a-zA-Z][._0-9a-zA-Z]\+'
" User transient variables
syntax match csVariable '\$\$[a-zA-Z][._0-9a-zA-Z]\+'
" Local variables
syntax match csVariable '\$_[a-zA-Z][._0-9a-zA-Z]\+'
"System variables (user input)
syntax match csSystemVariable '%\c\(inputrejoinder\|bot\|revisedinput\|command\|foreign\|impliedyou\|input\|ip\|length\|more\|morequt\|originalsentence\|parsed\|question\|quotation\|sentence\|tense\|userfirstline\|user\|userinput\|voicex\)'
"System variables (date & time & numbers)
syntax match csSystemVariable '%\c\(date\|daynumber\|fulltime\|timenumbers\|leapyear\|daylightsavings\|minute\|month\|monthname\|seek\|year\|rand\|zulutime\|day\|time\)'
"System variables (chatbot output)
syntax match csSystemVariable '%\c\(httpresponse\|response\|all\|document\|fact\|freetext\|freedict\|freefact\|maxmatchvariables\|mgression\|server\|rule\|topic\|actualtopic\|trace\|outputrejoinder\|lastquestion\)'
"System variables (build data)
syntax match csSystemVariable '%\(dict\|engine\|os\|script\|version\|pid\|restart\|language\)'
"Interchange variables"
syntax match csSystemVariable '%\c\(cs_afterreset\|cs_beforereset\|cs_token\|cs_response\|cs_jsontimeout\|cs_crashmsg\|cs_abstract\ace\|cs_control_pre\|cs_prepass\|cs_control_main\|cs_control_post\|botprompt\|userprompt\|cs_crashmsg\|cs_language\|cs_token\|cs_abcs_wildcardseparator\|cs_userfactlimit\|cs_response\|cs_randindex\|cs_utcoffset\|cs_randindex\|cs_bot\|cs_login\|\\$db_error\|\\$fiopen_error\|\\$document\|cs_externaltag\|cs_usermessagelimit\|\\$findtext_word\|\\$csmatch_start\|\\$csmatch_end\|cs_botid\)'
"Execution flow
syntax match csOperator '\(!\|==\|\(AND\|OR\)\|>=\|<=\|!=\|>\|<\|?\)'
syntax match csOperator '\(if\|else\|elsif\)'
" Boolean & state
syntax match csBoolean '\(null\|true\|false\)'
" Assigment
syntax match csOperator '\(?!\|+=\|-=\|\\*=\|=\|%=\|*=\|<<=\|>>=\|<<\|>>\|&=\|^=\)'
" Response control
syntax match csConstant '\#\c\(RESPONSE_UPPERSTART\|RESPONSE_REMOVESPACEBEFORECOMMA\|RESPONSE_ALTERUNDERSCORES\|ALL_RESPONSES\|RESP
"Token control
syntax match csConstant '\#\c\(DO_SUBSTITUTE_SYSTEM\|DO_ESSENTIALS\|DO_SUBSTITUTES\|DO_CONTRACTIONS\|DO_INTERJECTIONS\|DO_BRITISH\|ING\|DO_NOISE\|DO_PRIVATE\|DO_NUMBER_MERGE\|DO_PROPERNAME_MERGE\|DO_DATE_MERGE\|NO_PROPER_SPELLCHECK\|NO_LOWERCASE_PROPER_MERGE\|DORJECTION_SPLITTING\|DO_PARSE\|DO_POSTAG\|NO_IMPERATIVE\|NO_WITHIN\|NO_SENTENCE_END\|NO_HYPHEN_END\|NO_COLON_END\|NO_SEMICOLON_END\|LOWERCASE\|TOKEN_AS_IS\|SPLIT_QUOTE\|UNTOUCHED_INPUT\|JSON_DIRECT_FROM_OOB\|DO_CONDITIONAL_POSTAG\|NO_ERASE\|DO_SPLIT_UNDERSCORE\|MQUESTION\|LEAVE_QUOTE\|JSON_DIRECT_OOB\|NO_FIX_UTF\|QUESTIONMARK\)'
"Print output codes
syntax match csConstant '\#*\c\(OUTPUT_RAW\|OUTPUT_RETURNVALUE_ONLY\|OUTPUT_NOCOMMANUMBER\|OUTPUT_NOQUOTES\|OUTPUT_NOUNDERSCORE\)'
" End/nofail codes
syntax match csConstant '\#*\c\(NOFAIL\|FAIL\|CALL\|RULE\|LOOP\|TOPIC\|SENTENCE\|INPUT\|PLAN\)'
" TCP open
syntax match csConstant '\#*\c\(POST\|GET\|TRACE_TCP\|POSTU\|GETU\)'
" Logs
syntax match csConstant '\#*\c\(FILE\|OPEN\|CLOSE\)'
" Json
syntax match csConstant '\#*\c\(INDEX\|VALUE\)'
" Word
syntax match csConstant '\#*\c\(NOUN\|VERB\|ADJECTIVE\|ADVERB\|PREPOSITION\)'
" Facts
syntax match csConstant '\#*\c\(direct_s\|direct_v\|direct_o\|direct_sv\|direct_so\|direct_vo\|direct_svo\|Unipropogate\|FACTDEAD\
" POS
syntax match csConstant '\#*\c\(NOUN|VERB\|ESSENTIAL_POS\|ADJECTIVE\|ADVERB\|BASIC_POS\|PREPOSITION\|ESSENTIAL_FLAGS\|CONJUNCTION_ION_SUBORDINATE\|CONJUNCTION\|PREDETERMINER\|DETERMINER\|POSSESSIVE\|PRONOUN_POSSESSIVE\|POSSESSIVE_BITS\|DETERMINER_BITS\|COMMA\|RN\|PUNCTUATION\|QUOTE\|CURRENCY\|ADJECTIVE_NORMAL\|ADJECTIVE_NUMBER\|ADJECTIVE_NOUN\|ADJECTIVE_PARTICIPLE\|ADJECTIVE_BITS\|INTERJECIAL\|FOREIGN_WORD\|TO_INFINITIVE\|NOUN_ADJECTIVE\|NOUN_SINGULAR\|NOUN_PLURAL\|NOUN_PROPER_SINGULAR\|NOUN_PROPER_PLURAL\|NOUN_GERUNDINFINITIVE\|NOUN_PROPER\|NORMAL_NOUN_BITS\|NOUN_BITS\|VERB_PRESENT\|VERB_PRESENT_3PS\|VERB_PRESENT_PARTICIPLE\|VERB_PAST\|VERB_PASTFINITIVE\|PARTICLE\|VERB_BITS\|PRONOUN_SUBJECT\|PRONOUN_OBJECT\|PRONOUN_BITS\|AUX_DO\|AUX_HAVE\|AUX_BE\|AUX_VERB_PRESENT\|AUX_VERB_T\|AUX_VERB_TENSES\|AUX_VERB\|STARTTAGS\|AS_IS\)'
" Other special words
syntax match csConstant '\#*\c\(TOPRULES\|PENDING\|START\|END\|BOTH\|BOT\|USER\|AUTOSPACE\|HAS_SUBSTITUTE\|CONCEPT\|TOPIC\)'
"Built-in functions (topics)
syntax match csFunction '\^\c\(addtopic\|available\|cleartopics\|counttopics\|gambit\|getrule\|hasgambit\|keep\|lastused\|next\|popnder\|respond\|retry\|reuse\|sequence\|setrejoinder\|topicflags\)'
" Built-in functions (marking)
syntax match csFunction '\^\c\(mark\|unmark\|position\|setposition\|marked\)'
" Built-in functions (input)
syntax match csFunction '\^\c\(analyze\|capitalized\|input\|original\|position\|removetokenflags\|settokenflags\|setwildcardindex\|
" Built-in functions (number)
syntax match csFunction '\^\c\(compute\|timefromseconds\|timeinfofromseconds\|timetoeconds\)'
" Built-in functions (output)
syntax match csFunction '\^\c\(flushoutput\|insertprint\|keephistory\|lastsaid\|print\|preprint\|repeat\|reviseOutput\|savesentenceotrace\)'
" Built-in functions (output access)
syntax match csFunction '\^\c\(response\|responsequestion\|responseruleid\)'
" Built-in functions (print)
syntax match csFunction '\^\c\(postprintbefore\|postprintafter\|csboot\|csshotdown\)'
" Built-in functions (control flow)
syntax match csFunction '\^\c\(argument\|command\|end\|eval\|loop\|fail\|load\|match\|nofail\|notnull\|norejoinder\|nottrace\|returtext\)'
" Built-in functions (external access)
syntax match csFunction '\^\c\(system\|popen\|tcpopen\|export\|import\|debug\|log\|environment)\)'
" Built-in functions (json)
syntax match csFunction '\^\c\(jsonarrayinsert\|jsonarraydelete\|jsoncreate\|jsondelete\|jsongather\|jsonobjectinsert\|jsonopen\|jsjsonparse\|jsonpath\|jsonarraysize\|jsonobjectinsert\|jsonlabel\|jsonundecodestring\|jsoncopy\|jsonkind\|jsonreadcvs\|jsontree\)'
" Built-in functions (word manipulation)
syntax match csFunction '\^\c\(burst\|words\|canon\|explode\|extract\|findtext\|flags\|intersectwords\|join\|properties\|pos\|decodos\|partofspeech\|role\|tally\|rhyme\|substitute\|spell\|sexed\|uppercase\|addproperty\|define\|hasanyproperty\|hasallproperty\|removeproperty\|walkdictionary\|iterator\|wordinconcept\|setoriginal\|setcanon\|settag\|setrole\|tokenize\)'
" Built-in functions (multipurpose)
syntax match csFunction '\^\c\(disable\|enable\|length\|pick\|reset\|clearcontext\|authorized\|callstack\)'
" Built-in functions (facts)
syntax match csFunction '\^\c\(result\|findfact\|query\|first\|last\|pick\|sort\|delete\|length\|nth\|unpackfactref\|save\|addpropeeateattribute\|createfact\|writefact\|revisefact\|field\|find\|findmarkedfact\|flushfacts\|gambittopics\|intersectfacts\|keywordtop|next\|pendingtopics\|pick\|querytopics\|removeproperty\|reset\|query\|save\|unduplicate\|uniquefacts\|unpackfactref\|importfacts\|ze\|match\)'
highligh link csPreProc PreProc
highlight link csStatement Statement
highlight link csComment Comment
highlight link csTestComment String "Todo "SpecialComment
highlight link csKeyword Statement "Keyword
highlight link csDelimiter SpecialChar "Character "Delimiter
highlight link csTopicName Special
highlight link csFunction Special
highlight link csMatchVariable Identifier "Todo "Statement
highlight link csSystemVariable Identifier
highlight link csVariable Identifier
highlight link csOperator Operator
highlight link csBoolean Boolean
highlight link csConstant Constant
highlight link csString String
highlight link csLabel Todo
let b:current_syntax = 'ChatScript'
" *Comment any comment
"
" *Constant any constant
" String a string constant: "this is a string"
" Character a character constant: 'c', '\n'
" Number a number constant: 234, 0xff
" Boolean a boolean constant: TRUE, false
" Float a floating point constant: 2.3e10
"
" *Identifier any variable name
" Function function name (also: methods for classes)
"
" *Statement any statement
" Conditional if, then, else, endif, switch, etc.
" Repeat for, do, while, etc.
" Label case, default, etc.
" Operator "sizeof", "+", "*", etc.
" Keyword any other keyword
" Exception try, catch, throw
"
" *PreProc generic Preprocessor
" Include preprocessor #include
" Define preprocessor #define
" Macro same as Define
" PreCondit preprocessor #if, #else, #endif, etc.
"
" *Type int, long, char, etc.
" StorageClass static, register, volatile, etc.
" Structure struct, union, enum, etc.
" Typedef A typedef
"
" *Special any special symbol
" SpecialChar special character in a constant
" Tag you can use CTRL-] on this
" Delimiter character that needs attention
" SpecialComment special things inside a comment
" Debug debugging statements
"
" *Underlined text that stands out, HTML links
" *Ignore left blank, hidden |hl-Ignore|
" *Error any erroneous construct
" *Todo anything that needs extra attention; mostly the
" keywords TODO FIXME and XXX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment