diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-07-18 07:45:58 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-07-18 07:45:58 +0100 |
commit | 8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642 (patch) | |
tree | c53977d1284347bb1d5963ddb4dc7723c40c6e55 /micro-vim | |
download | micro-lang-8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642.tar.gz micro-lang-8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642.zip |
First public release
Diffstat (limited to 'micro-vim')
-rw-r--r-- | micro-vim/ftdetect/micro.vim | 3 | ||||
-rw-r--r-- | micro-vim/ftplugin/micro.vim | 26 | ||||
-rw-r--r-- | micro-vim/syntax/micro.vim | 90 |
3 files changed, 119 insertions, 0 deletions
diff --git a/micro-vim/ftdetect/micro.vim b/micro-vim/ftdetect/micro.vim new file mode 100644 index 0000000..cd69d70 --- /dev/null +++ b/micro-vim/ftdetect/micro.vim @@ -0,0 +1,3 @@ +autocmd BufNewFile,BufRead *.micro set filetype=micro +autocmd BufNewFile,BufRead *.cro set filetype=micro + diff --git a/micro-vim/ftplugin/micro.vim b/micro-vim/ftplugin/micro.vim new file mode 100644 index 0000000..ea3ce5a --- /dev/null +++ b/micro-vim/ftplugin/micro.vim @@ -0,0 +1,26 @@ + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo-=C + +setlocal suffixesadd+=.micro,.cro +setlocal comments=b://,fb:- +setlocal commentstring=//\ %s + +setlocal smartindent cindent + +setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab + +" run make editing a micro file and it will be parsed for errors +setlocal makeprg=micro\ -parse\ % +setlocal errorformat=%f:%l\ col\ %c\ %trror:\ %m + +let b:undo_ftplugin="setl com<" + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/micro-vim/syntax/micro.vim b/micro-vim/syntax/micro.vim new file mode 100644 index 0000000..f620579 --- /dev/null +++ b/micro-vim/syntax/micro.vim @@ -0,0 +1,90 @@ +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +syn clear +syn sync fromstart + +syn match microNumber /\<[0-9]\d*\>/ + +syn match microEscapeHex /\\x\x{2}/ transparent contained +syn match microEscapeChar /\\[nt\\']/ transparent contained +syn match microEscapeString /\\[nt\\"]/ transparent contained + +syn cluster microCharacterGroup contains=microEscapeChar,microEscapeHex +syn region microCharacter start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=@microCharacterGroup + +syn cluster microStringGroup contains=microEscapeString,microEscapeHex +syn region microString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=@Spell,microStringGroup + +syn keyword microConditional if else continue break +syn keyword microRepeat for in +syn keyword microType number bool string func +syn keyword microBoolean true false +syn keyword microKeyword len +syn keyword microStatement return nextgroup=microTagE skipwhite skipempty + +syn match microTagE /!?/ display contained + +"" this is probably not correct +syn match microOperator display "?\|+\|-\|/\|*\|=\|=\|\^\|&\||\|!\|!=\|>\|>=\|<\|<=\|\~\|%" +syn match microOperator display "&&\|||" + +syn keyword microKeyword def nextgroup=microFuncName skipwhite skipempty +syn match microFuncName /[_a-zA-Z][_a-zA-Z0-9]*/ nextgroup=microFuncParams display contained +syn region microFuncParams start=/(/ end=/)/ contains=microVarIdent,microNumber,microChar nextgroup=microVarType,microVarArray skipwhite contained + +syn match mucroPropStart /\./ nextgroup=microProp skipwhite +syn match microProp /[_a-zA-Z][_a-zA-Z0-9]*/ display contained + +syn keyword microKeyword var nextgroup=microVarIdent skipwhite skipempty +syn keyword microKeyword const nextgroup=microVarIdent skipwhite skipempty +syn match microVarIdent /[_a-zA-Z][_a-zA-Z0-9]*/ nextgroup=microVarType,microVarArray skipwhite +syn match microVarArray /\[[0-9]*\]/ nextgroup=microVarType transparent contained skipwhite +syn match microVarType /[_a-zA-Z][_a-zA-Z0-9]*/ display contained + +syn match microCall /[_a-zA-Z][_a-zA-Z0-9]*(/he=e-1,me=e-1 + +syn region microIndex start=/\[/ end=/\]/ contains=microNumber,microChar,microIndexIdent,microIndexCall +syn match microIndexIdent /[_a-zA-Z][_a-zA-Z0-9]*/ display contained +syn match microIndexCall /[_a-zA-Z][_a-zA-Z0-9]*(/he=e-1,me=e-1 display contained + +syn keyword microBuiltin println panic + +syn region microBlock start="{" end="}" transparent fold + +syn keyword microCommentTodo TODO FIXME XXX BUG contained +syn match microLineComment "\/\/.*" contains=@Spell,microCommentTodo + +hi def link microLineComment Comment +hi def link microCommentTodo Todo +hi def link microNumber Number +hi def link microCharacter Character +hi def link microString String +hi def link microStrEmbeddedQuote String +hi def link microConditional Conditional +hi def link microRepeat Repeat +hi def link microOperator Operator +hi def link microType Type +hi def link microVarType Type +hi def link microBoolean Boolean +hi def link microKeyword Keyword +hi def link microStatement Statement +hi def link microTagE Keyword + +hi def link microBuiltin Function +hi def link microFuncName Function +hi def link microCall Function +hi def link microProp Identifier + +hi def link microIndexIdent Number +hi def link microIndexCall Function + +let b:current_syntax = "micro" + +let &cpo = s:cpo_save +unlet s:cpo_save + |