Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support variables with non-alphabetical suffixes #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions syntax/ChatScript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ endif
syntax match csWildcard '\*'


syntax match csTopicName '\v\~[a-z_\.A-Z]*'
syntax match csFunction '\v\^[a-z_\.A-Z]+'
syntax match csTopicName '\v\~[a-z_\.A-Z][_0-9a-zA-Z]*'
syntax match csFunction '\v\^[a-z_\.A-Z][_0-9a-zA-Z]*'

" Named Constant #DO_SUBSTITUTE_SYSTEM
syntax match csNamedConstant '#[a-zA-Z][\._0-9a-zA-Z]*'

" User permanent variables
" System variables
syntax match csSystemVariable '\v\%[a-zA-Z][\._0-9a-zA-Z\[\]]*'

" User permanent variables (global) $name
syntax match csPermanentVariable '\v\$[a-zA-Z][\._0-9a-zA-Z\[\]]*'

" User transient variables
" User transient variables (global) $$mood
syntax match csTransientVariable '\v\$\$[a-zA-Z][\._0-9a-zA-Z\[\]]*'

" Local variables
" Local variables $_heartbeat
syntax match csLocalVariable '\v\$_[a-zA-Z][\._0-9a-zA-Z\[\]]*'

" Fact set
Expand All @@ -30,12 +35,12 @@ syntax match csFactset '@\(\d*\|\*\)'
" Boolean & state
syntax match csBoolean '\v(null|true|false)'

" Assigment
" Assignment
syntax match csOperator '\v(\?!|\+\=|-\=|\=|\%\=|\*\=|<<\=|>>\=|<<|>>|&\=|\^\=)'
syntax match csOperator '\v(\'|!|\?|\=\=|and|or|AND|OR|>\=|<\=|!\=|>|<)'

" Execution flow
syntax match csOperator '\v(\s*^if\s*|\s*if\s*|\s*else\s*|\s*^else\s*|\s*else if\s*|\s*^else if\s*|\s*loop\s*|\s*^loop\s*)'
syntax match csOperator '\v(\s*^if\s*|\s*if\s*|\s*else\s*|\s*^else\s*|\s*else if\s*|\s*^else if\s*|\s*loop\s+|\s*^loop\s+)'

" Match variables
syntax match csMatchVariable '\v_\d+'
Expand All @@ -53,9 +58,16 @@ syntax match csBlockDelimiter '\v[{}]'
syntax match csKeyword '\v(topic:|concept:|table:|tablemacro:|outputmacro:|patternmacro:|dualmacro:)'
syntax match csKeyword '\v(bot:|data:|canon:|query:|plan:|describe:|replace:)'

syntax match csComment '\v^\s*#.*$'
syntax match csTestComment '\v^\s*#!.*$'
" baseline (original)
" syntax match csComment '\v^\s*#.*$'
" syntax match csTestComment '\v^\s*#!.*$'

" Works with halfway comments
syntax match csComment '#\s.*$'
syntax match csTestComment '#!\s.*$'

" comment block ##<< junk multiple lines ##>>
syntax region csCommentBlock start='##<<.*$' end='##>>.*$'

syntax match csString '".*"'
syntax match csString '\'.*\''
Expand All @@ -74,27 +86,28 @@ highlight csOperator ctermfg=215
highlight csSpecialChar ctermfg=12
highlight csFactset ctermfg=12

highlight csComment ctermfg=8
highlight csTestComment ctermfg=7
highlight csComment ctermfg=11
highlight csTestComment ctermfg=3
highlight csCommentBlock ctermfg=3

highlight csPatternDelimiter ctermfg=15
highlight csBracketsDelimiter ctermfg=7
highlight csBlockDelimiter ctermfg=215


" variables
highlight csSystemVariable ctermfg=15
highlight csSystemVariable ctermfg=13
highlight csPermanentVariable ctermfg=10
highlight csMatchVariable ctermfg=123
highlight csWildcard ctermfg=123
highlight csLocalVariable ctermfg=35
highlight csTransientVariable ctermfg=24
highlight csTransientVariable ctermfg=34

highlight csTopicName ctermfg=10
highlight csTopicName ctermfg=62
highlight csFunction ctermfg=37

highlight csBoolean ctermfg=15
highlight csConstant ctermfg=15
highlight csBoolean ctermfg=9
highlight csNamedConstant ctermfg=1

" strings
highlight csString ctermfg=69
Expand Down