diff --git a/editors/vim/ftdetect/chl.vim b/editors/vim/ftdetect/chl.vim new file mode 100644 index 0000000..5fa802b --- /dev/null +++ b/editors/vim/ftdetect/chl.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.chl set filetype=chl diff --git a/editors/vim/indent/chl.vim b/editors/vim/indent/chl.vim new file mode 100644 index 0000000..e182dcd --- /dev/null +++ b/editors/vim/indent/chl.vim @@ -0,0 +1,30 @@ +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +if (!has("cindent") || !has("eval")) + finish +endif + +setlocal cindent + +" L0 -> 0 indent for jump labels (i.e. case statement in c). +" j1 -> indenting for "javascript object declarations" +" J1 -> see j1 +" w1 -> starting a new line with `(` at the same indent as `(` +" m1 -> if `)` starts a line, match its indent with the first char of its +" matching `(` line +" (s -> use one indent, when starting a new line after a trailing `(` +setlocal cinoptions=L0,m1,(s,j1,J1,l1 + +" cinkeys: controls what keys trigger indent formatting +" 0{ -> { +" 0} -> } +" 0) -> ) +" 0] -> ] +" !^F -> make CTRL-F (^F) reindent the current line when typed +" o -> when or `o` is used +" O -> when the `O` command is used +setlocal cinkeys=0{,0},0),0],!^F,o,O diff --git a/editors/vim/syntax/chl.vim b/editors/vim/syntax/chl.vim new file mode 100644 index 0000000..8316047 --- /dev/null +++ b/editors/vim/syntax/chl.vim @@ -0,0 +1,102 @@ +" Vim syntax file +" Language: Couch Lang +" 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 + diff --git a/test.chl b/test.chl new file mode 100644 index 0000000..70febb1 --- /dev/null +++ b/test.chl @@ -0,0 +1,12 @@ +let a = 5; + +if 1 == 0 and true { + return true; +} + +// safadkjasda + +/* +sdasd +*/ +