thiselang/editors/vim/syntax/chl.vim
2023-03-16 17:59:42 +01:00

103 lines
3.2 KiB
VimL

" Vim syntax file
" Language: Couch
" Maintainer: Simon From Jakobsen
" Latest Revision: 1 January 1970
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
let s:chl_syntax_keywords = {
\ 'chlConditional' :["if"
\ , "else"
\ , "match"
\ , ]
\ , 'chlRepeat' :["while"
\ , "for"
\ , ]
\ , 'chlExecution' :["return"
\ , "break"
\ , "continue"
\ , ]
\ , 'chlBoolean' :["true"
\ , "false"
\ , ]
\ , 'chlKeyword' :["fn"
\ , ]
\ , 'chlWordOperator' :["not"
\ , "and"
\ , "or"
\ , "as"
\ , "in"
\ , ]
\ , 'chlVarDecl' :["mut"
\ , "let"
\ , ]
\ , }
function! s:syntax_keyword(dict)
for key in keys(a:dict)
execute 'syntax keyword' key join(a:dict[key], ' ')
endfor
endfunction
call s:syntax_keyword(s:chl_syntax_keywords)
syntax match chlDecNumber display "\v<\d%(_?\d)*"
syntax match chlHexNumber display "\v<0x\x%(_?\x)*"
syntax match chlFatArrowOperator display "\V=>"
syntax match chlRangeOperator display "\V.."
syntax match chlOperator display "\V\[-+/*=^&?|!><%~:;,]"
syntax match chlFunction /\w\+\s*(/me=e-1,he=e-1
syntax region chlBlock start="{" end="}" transparent fold
syntax region chlCommentLine start="//" end="$" contains=chlTodo
syntax region chlCommentBlock matchgroup=chlCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=chlTodo,chlCommentBlockNest
syntax region chlCommentBlockNest matchgroup=chlCommentBlock start="/\*" end="\*/" contains=chlTodo,chlCommentBlockNest contained transparent
syntax keyword chlTodo contained TODO FIXME XXX NB NOTE SAFETY
syntax region chlString matchgroup=chlStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline contains=chlEscape
syntax match chlEscape display contained /\\./
highlight default link chlDecNumber chlNumber
highlight default link chlHexNumber chlNumber
highlight default link chlWordOperator chlOperator
highlight default link chlFatArrowOperator chlOperator
highlight default link chlRangeOperator chlOperator
highlight default link chlKeyword Keyword
highlight default link chlCommentLine Comment
highlight default link chlCommentBlock Comment
highlight default link chlString String
highlight default link chlStringDelimiter String
highlight default link chlChar String
highlight default link chlCharDelimiter String
highlight default link chlEscape Special
highlight default link chlBoolean Boolean
highlight default link chlConstant Constant
highlight default link chlNumber Number
highlight default link chlOperator Operator
highlight default link chlStructure Structure
highlight default link chlExecution Keyword
highlight default link chlConditional Conditional
highlight default link chlRepeat Repeat
highlight default link chlVarDecl Define
highlight default link chlFunction Function
delfunction s:syntax_keyword
let b:current_syntax = "chl"
let &cpo = s:cpo_save
unlet! s:cpo_save