diff --git a/README.md b/README.md index 49fcd4f..3fb1778 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -This is a vim plugin for the [SSS programming language](https://github.com/bruce-hil/sss). +This is a vim plugin for the [Tomo programming language](https://github.com/bruce-hil/tomo). diff --git a/ftdetect/sss.vim b/ftdetect/tomo.vim similarity index 50% rename from ftdetect/sss.vim rename to ftdetect/tomo.vim index 389cfe0..94d5efb 100644 --- a/ftdetect/sss.vim +++ b/ftdetect/tomo.vim @@ -1,5 +1,5 @@ -" Language: SSS +" Language: Tomo " Maintainer: Bruce Hill " License: WTFPL -autocmd BufNewFile,BufRead *.sss set filetype=sss +autocmd BufNewFile,BufRead *.tm set filetype=tomo diff --git a/ftplugin/sss.vim b/ftplugin/tomo.vim similarity index 93% rename from ftplugin/sss.vim rename to ftplugin/tomo.vim index 5239374..0b56f40 100644 --- a/ftplugin/sss.vim +++ b/ftplugin/tomo.vim @@ -1,4 +1,4 @@ -" Language: SSS +" Language: Tomo " Maintainer: Bruce Hill " License: WTFPL diff --git a/indent/sss.vim b/indent/tomo.vim similarity index 86% rename from indent/sss.vim rename to indent/tomo.vim index 3022546..4c06c8a 100644 --- a/indent/sss.vim +++ b/indent/tomo.vim @@ -1,4 +1,4 @@ -" Language: SSS +" Language: Tomo " Maintainer: Bruce Hill " License: WTFPL @@ -9,15 +9,15 @@ endif let b:did_indent = 1 setlocal autoindent -setlocal indentexpr=GetSSSIndent() +setlocal indentexpr=GetTomoIndent() setlocal indentkeys+=-: " Only define the function once. -if exists("*GetSSSIndent") +if exists("*GetTomoIndent") finish endif -function! GetSSSIndent() +function! GetTomoIndent() let line = getline(v:lnum) let current_ind = indent(v:lnum) let previousNum = prevnonblank(v:lnum - 1) diff --git a/syntax/sss.vim b/syntax/sss.vim deleted file mode 100644 index 55c3ca9..0000000 --- a/syntax/sss.vim +++ /dev/null @@ -1,178 +0,0 @@ -" Language: SSS -" Maintainer: Bruce Hill -" License: WTFPL - -" Bail if our syntax is already loaded. -if exists('b:current_syntax') && b:current_syntax == 'sss' - finish -endif - -syn match SSSErrorWord /\i*/ contained -hi def link SSSErrorWord Error - -syn match SSSVar /[a-zA-Z_][a-zA-Z_0-9]*/ - -syn match SSSNumber /0x[0-9a-fA-F_]\+%\?\|[0-9][0-9_]*\(\.\([0-9][0-9_]*\|\.\@!\)\)\?\(e[0-9_]\+\)\?%\?\|\.\@/he=s-1 contains= contained -syn region SSSDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=SSSStringInterp contained -hi def link SSSDSLString String - -syn match SSSArray /\[/ nextgroup=SSSTypeAnnotation -syn match SSSTable /{/ nextgroup=SSSTypeAnnotation - -syn match SSSDocTest /^\s*>>>/ -syn region SSSDocTest start=/^\s*===/ end=/$/ -hi SSSDocTest ctermfg=gray - -syn match SSSDocError /!!!.*/ -hi SSSDocError ctermfg=red cterm=italic - -syn match SSSDSL /\$\w*/ nextgroup=SSSString,SSSCustomStringInterp -hi def link SSSDSL String -hi SSSDSL ctermfg=white cterm=bold - -syn match SSSCustomStringInterp /[~!@#$%^&*+=\?]\?/ contained nextgroup=SSSDSLString -hi SSSCustomStringInterp ctermfg=gray - -syn match SSSStringDollar /\$:\?/ contained -hi SSSStringDollar ctermfg=LightBlue - -syn match SSSStringAt /@/ contained -hi SSSStringAt ctermfg=LightBlue - -syn match SSSStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*/ contained -hi SSSStringInterpWord ctermfg=LightBlue - -syn match SSSStringInterp /\$:\?/ contained nextgroup=SSSStringDollar,SSSStringInterpWord,SSSParenGroup,@SSSAll -hi SSSStringInterp ctermfg=LightBlue - -syn match SSSEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\)\(-\([abnrtv]\|x\x\x\|\d\{3}\)\)\?\|\\./ -hi SSSEscape ctermfg=LightBlue - -syn keyword SSSExtern extern -hi def link SSSExtern Statement - -syn keyword SSSConditional if unless elseif else when then defer convert -hi def link SSSConditional Conditional - -syn keyword SSSLoop for between while do until with repeat -hi def link SSSLoop Repeat - -syn keyword SSSFail fail -hi def link SSSFail Exception - -syn keyword SSSStatement stop skip fail pass return del struct lang -hi def link SSSStatement Statement - -syn keyword SSSNull NONE -hi SSSNull ctermfg=red - -syn region SSSUse matchgroup=Keyword start=/\/ matchgroup=SSSDelim end=/$\|;/ -hi def link SSSUse String - -syn match SSSArgDefault /=/ nextgroup=@SSSAll skipwhite contained -hi def link SSSArgDefault Operator -syn match SSSReturnSignature /->/ nextgroup=SSSType skipwhite contained -hi def link SSSReturnSignature Operator -syn region SSSFnArgSignature start=/(/ end=/)/ contains=SSSVar,SSSDelim,SSSTypeAnnotation,SSSArgDefault nextgroup=SSSReturnSignature skipwhite contained -syn match SSSFnName /\<[a-zA-Z_][a-zA-Z_0-9]*\>/ nextgroup=SSSFnArgSignature skipwhite contained -hi def link SSSFnName Function -syn keyword SSSFuncDef func nextgroup=SSSFnName skipwhite -hi def link SSSFuncDef Keyword - -syn match SSSTagEquals /=/ skipwhite nextgroup=SSSErrorWord,SSSNumber contained -hi def link SSSTagEquals Operator -syn match SSSTagType /(/ nextgroup=SSSType contained -syn match SSSTag /[a-zA-Z_]\i*/ nextgroup=SSSTagType contained -hi SSSTag cterm=bold - -syn keyword SSSEnum enum skipwhite nextgroup=SSSTaggedUnion -hi def link SSSEnum Keyword -syn region SSSTaggedUnion start=/:=/ skip=/|/ end=/$/ contains=SSSTag,SSSTagEquals contained - -" syn region SSSFnDecl start=/\/ end=/(\@=\|$/ contains=SSSFnName,SSSKeyword - -syn keyword SSSBoolean yes no -hi def link SSSBoolean Boolean - -syn keyword SSSNil nil -hi SSSNil cterm=bold ctermfg=cyan - -syn match SSSStructName /\w\+\( *{\)\@=/ -hi SSSStructName cterm=bold - -syn keyword SSSOperator in and or xor is not mod mod1 _min_ _max_ _mix_ -syn match SSSOperator ;\([a-zA-Z0-9_)] *\)\@<=/; -syn match SSSOperator ;[+*^<>=-]=\?; -syn match SSSOperator /[:!]\?=/ -syn match SSSOperator /[#?:]/ -hi def link SSSOperator Operator - -syn match SSSDelim /,/ -hi def link SSSDelim Delimiter - -syn match SSSTableValueType /:/ nextgroup=SSSType contained -hi def link SSSTableValueType Type -syn match SSSTypeDelim /,/ contained -hi def link SSSTypeDelim Type -syn match SSSAssoc /=/ contained -hi def link SSSAssoc Type -syn region SSSType start=/\[/ end=/\]\|\():\)\@=\|$/ contains=SSSType contained nextgroup=SSSTableValueType -syn region SSSType start=/{/ end=/}\|\():\)\@=\|$/ contains=SSSType,SSSAssoc contained nextgroup=SSSTableValueType -syn region SSSType start=/func(/ end=/) *\(->\)\?/ contains=SSSType,SSSTypeDelim nextgroup=SSSType contained -syn match SSSType /[a-zA-Z_]\i*/ contained nextgroup=SSSTableValueType -syn match SSSType /\$[a-zA-Z_0-9]\+/ contained nextgroup=SSSTableValueType -syn match SSSType /[@?&]\+/ contained nextgroup=SSSType -hi def link SSSType Type - -syn match SSSTypeAnnotation /:=\@!/ nextgroup=SSSType contained -hi def link SSSTypeAnnotation Operator - -syn region SSSComment start=;#; end=/$/ -hi def link SSSComment Comment - -syn region SSSSay start=;!!; end=/$/ contains=SSSEscape,SSSStringInterp -hi SSSSay ctermfg=white cterm=bold - -syn region SSSInlineCParens start=/(/ end=/)/ contains=SSSInlineCParens contained -hi def link SSSInlineCParens String - -syn region SSSInlineCBraces start=/{/ end=/}/ contains=SSSInlineCBraces contained -hi def link SSSInlineCBraces String - -syn match SSSInlineC ;inline C *; nextgroup=SSSInlineCBraces,SSSInlineCParens -hi def link SSSInlineC Keyword - -syn region SSSParenGroup start=/(/ end=/)/ contains=@SSSAll,SSSParenGroup contained - -syn match SSSLinkerDirective ;^\s*!link.*$; -hi SSSLinkerDirective ctermbg=blue ctermfg=black - -syn cluster SSSAll contains=SSSVar,SSSComment,SSSChar,SSSString,SSSDSL,SSSPath,SSSKeyword,SSSOperator, - \SSSConditional,SSSLoop,SSSFail,SSSNull,SSSStatement,SSSStructure,SSSTypedef,SSSEmptyTable,SSSUse, - \SSSNumber,SSSFnDecl,SSSBoolean,SSSNil,SSSDocTest,SSSDocError,SSSArray,SSSTable, - \SSSLinkerDirective,SSSInlineC - -if !exists('b:current_syntax') - let b:current_syntax = 'bpeg' -endif diff --git a/syntax/tomo.vim b/syntax/tomo.vim new file mode 100644 index 0000000..a9fc80d --- /dev/null +++ b/syntax/tomo.vim @@ -0,0 +1,178 @@ +" Language: Tomo +" Maintainer: Bruce Hill +" License: WTFPL + +" Bail if our syntax is already loaded. +if exists('b:current_syntax') && b:current_syntax == 'tomo' + finish +endif + +syn match TomoErrorWord /\i*/ contained +hi def link TomoErrorWord Error + +syn match TomoVar /[a-zA-Z_][a-zA-Z_0-9]*/ + +syn match TomoNumber /0x[0-9a-fA-F_]\+%\?\|[0-9][0-9_]*\(\.\([0-9][0-9_]*\|\.\@!\)\)\?\(e[0-9_]\+\)\?%\?\|\.\@/he=s-1 contains= contained +syn region TomoDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=TomoStringInterp contained +hi def link TomoDSLString String + +syn match TomoArray /\[/ nextgroup=TomoTypeAnnotation +syn match TomoTable /{/ nextgroup=TomoTypeAnnotation + +syn match TomoDocTest /^\s*>>>/ +syn region TomoDocTest start=/^\s*===/ end=/$/ +hi TomoDocTest ctermfg=gray + +syn match TomoDocError /!!!.*/ +hi TomoDocError ctermfg=red cterm=italic + +syn match TomoDSL /\$\w*/ nextgroup=TomoString,TomoCustomStringInterp +hi def link TomoDSL String +hi TomoDSL ctermfg=white cterm=bold + +syn match TomoCustomStringInterp /[~!@#$%^&*+=\?]\?/ contained nextgroup=TomoDSLString +hi TomoCustomStringInterp ctermfg=gray + +syn match TomoStringDollar /\$:\?/ contained +hi TomoStringDollar ctermfg=LightBlue + +syn match TomoStringAt /@/ contained +hi TomoStringAt ctermfg=LightBlue + +syn match TomoStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*/ contained +hi TomoStringInterpWord ctermfg=LightBlue + +syn match TomoStringInterp /\$:\?/ contained nextgroup=TomoStringDollar,TomoStringInterpWord,TomoParenGroup,@TomoAll +hi TomoStringInterp ctermfg=LightBlue + +syn match TomoEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\)\(-\([abnrtv]\|x\x\x\|\d\{3}\)\)\?\|\\./ +hi TomoEscape ctermfg=LightBlue + +syn keyword TomoExtern extern +hi def link TomoExtern Statement + +syn keyword TomoConditional if unless elseif else when then defer convert +hi def link TomoConditional Conditional + +syn keyword TomoLoop for between while do until with repeat +hi def link TomoLoop Repeat + +syn keyword TomoFail fail +hi def link TomoFail Exception + +syn keyword TomoStatement stop skip fail pass return del struct lang +hi def link TomoStatement Statement + +syn keyword TomoNull NONE +hi TomoNull ctermfg=red + +syn region TomoUse matchgroup=Keyword start=/\/ matchgroup=TomoDelim end=/$\|;/ +hi def link TomoUse String + +syn match TomoArgDefault /=/ nextgroup=@TomoAll skipwhite contained +hi def link TomoArgDefault Operator +syn match TomoReturnSignature /->/ nextgroup=TomoType skipwhite contained +hi def link TomoReturnSignature Operator +syn region TomoFnArgSignature start=/(/ end=/)/ contains=TomoVar,TomoDelim,TomoTypeAnnotation,TomoArgDefault nextgroup=TomoReturnSignature skipwhite contained +syn match TomoFnName /\<[a-zA-Z_][a-zA-Z_0-9]*\>/ nextgroup=TomoFnArgSignature skipwhite contained +hi def link TomoFnName Function +syn keyword TomoFuncDef func nextgroup=TomoFnName skipwhite +hi def link TomoFuncDef Keyword + +syn match TomoTagEquals /=/ skipwhite nextgroup=TomoErrorWord,TomoNumber contained +hi def link TomoTagEquals Operator +syn match TomoTagType /(/ nextgroup=TomoType contained +syn match TomoTag /[a-zA-Z_]\i*/ nextgroup=TomoTagType contained +hi TomoTag cterm=bold + +syn keyword TomoEnum enum skipwhite nextgroup=TomoTaggedUnion +hi def link TomoEnum Keyword +syn region TomoTaggedUnion start=/:=/ skip=/|/ end=/$/ contains=TomoTag,TomoTagEquals contained + +" syn region TomoFnDecl start=/\/ end=/(\@=\|$/ contains=TomoFnName,TomoKeyword + +syn keyword TomoBoolean yes no +hi def link TomoBoolean Boolean + +syn keyword TomoNil nil +hi TomoNil cterm=bold ctermfg=cyan + +syn match TomoStructName /\w\+\( *{\)\@=/ +hi TomoStructName cterm=bold + +syn keyword TomoOperator in and or xor is not mod mod1 _min_ _max_ _mix_ +syn match TomoOperator ;\([a-zA-Z0-9_)] *\)\@<=/; +syn match TomoOperator ;[+*^<>=-]=\?; +syn match TomoOperator /[:!]\?=/ +syn match TomoOperator /[#?:]/ +hi def link TomoOperator Operator + +syn match TomoDelim /,/ +hi def link TomoDelim Delimiter + +syn match TomoTableValueType /:/ nextgroup=TomoType contained +hi def link TomoTableValueType Type +syn match TomoTypeDelim /,/ contained +hi def link TomoTypeDelim Type +syn match TomoAssoc /=/ contained +hi def link TomoAssoc Type +syn region TomoType start=/\[/ end=/\]\|\():\)\@=\|$/ contains=TomoType contained nextgroup=TomoTableValueType +syn region TomoType start=/{/ end=/}\|\():\)\@=\|$/ contains=TomoType,TomoAssoc contained nextgroup=TomoTableValueType +syn region TomoType start=/func(/ end=/) *\(->\)\?/ contains=TomoType,TomoTypeDelim nextgroup=TomoType contained +syn match TomoType /[a-zA-Z_]\i*/ contained nextgroup=TomoTableValueType +syn match TomoType /\$[a-zA-Z_0-9]\+/ contained nextgroup=TomoTableValueType +syn match TomoType /[@?&]\+/ contained nextgroup=TomoType +hi def link TomoType Type + +syn match TomoTypeAnnotation /:=\@!/ nextgroup=TomoType contained +hi def link TomoTypeAnnotation Operator + +syn region TomoComment start=;#; end=/$/ +hi def link TomoComment Comment + +syn region TomoSay start=;!!; end=/$/ contains=TomoEscape,TomoStringInterp +hi TomoSay ctermfg=white cterm=bold + +syn region TomoInlineCParens start=/(/ end=/)/ contains=TomoInlineCParens contained +hi def link TomoInlineCParens String + +syn region TomoInlineCBraces start=/{/ end=/}/ contains=TomoInlineCBraces contained +hi def link TomoInlineCBraces String + +syn match TomoInlineC ;inline C *; nextgroup=TomoInlineCBraces,TomoInlineCParens +hi def link TomoInlineC Keyword + +syn region TomoParenGroup start=/(/ end=/)/ contains=@TomoAll,TomoParenGroup contained + +syn match TomoLinkerDirective ;^\s*!link.*$; +hi TomoLinkerDirective ctermbg=blue ctermfg=black + +syn cluster TomoAll contains=TomoVar,TomoComment,TomoChar,TomoString,TomoDSL,TomoPath,TomoKeyword,TomoOperator, + \TomoConditional,TomoLoop,TomoFail,TomoNull,TomoStatement,TomoStructure,TomoTypedef,TomoEmptyTable,TomoUse, + \TomoNumber,TomoFnDecl,TomoBoolean,TomoNil,TomoDocTest,TomoDocError,TomoArray,TomoTable, + \TomoLinkerDirective,TomoInlineC + +if !exists('b:current_syntax') + let b:current_syntax = 'tomo' +endif