mu/mu.vim

99 lines
4.0 KiB
VimL
Raw Normal View History

2015-01-14 03:25:31 +00:00
" Vim syntax file
" Language: mu
" Maintainer: Kartik Agaram <mu@akkartik.com>
" URL: http://github.com/akkartik/mu
" License: public domain
"
2015-09-06 23:32:41 +00:00
" Copy this into your ftplugin directory, and add the following to your vimrc
" or to .vim/ftdetect/mu.vim:
2017-07-13 14:20:13 +00:00
" autocmd BufReadPost,BufNewFile *.mu set filetype=mu
2015-01-14 03:25:31 +00:00
let s:save_cpo = &cpo
set cpo&vim
2015-01-14 06:56:49 +00:00
" todo: why does this periodically lose syntax, like on file reload?
" $ vim x.mu
" :e
"? if exists("b:syntax")
"? finish
"? endif
"? let b:syntax = "mu"
2015-01-14 03:25:31 +00:00
setlocal iskeyword=@,48-57,?,!,_,$,-
2016-10-22 23:56:07 +00:00
setlocal formatoptions-=t " Mu programs have long lines
2015-05-20 07:23:01 +00:00
setlocal formatoptions+=c " but comments should still wrap
2015-01-14 03:25:31 +00:00
2018-07-01 04:58:55 +00:00
syntax match muComment /#.*$/ | highlight link muComment Comment
syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment
syntax match muComment /;.*$/ | highlight link muComment Comment
syntax match muSalientComment /;;.*$/ | highlight link muSalientComment SalientComment
set comments+=n:#
2018-07-01 04:58:55 +00:00
syntax match muCommentedCode "#? .*" | highlight link muCommentedCode CommentedCode
let b:cmt_head = "#? "
2015-01-14 03:25:31 +00:00
2018-07-01 04:58:55 +00:00
syntax match muDelimiter "[{}]" | highlight link muDelimiter Delimiter
2017-12-28 04:19:46 +00:00
2016-10-22 23:56:07 +00:00
" Mu strings are inside [ ... ] and can span multiple lines
2015-05-10 19:50:28 +00:00
" don't match '[' at end of line, that's usually code
syntax match muLiteral %^[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*\|[ ,]\@<=[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*%
2015-05-10 19:50:28 +00:00
syntax region muString start=+\[[^\]]+ end=+\]+
2015-05-10 19:18:20 +00:00
syntax match muString "\[\]"
2015-01-14 03:25:31 +00:00
highlight link muString String
2016-10-22 23:56:07 +00:00
" Mu syntax for representing the screen in scenarios
2015-05-10 19:50:28 +00:00
syntax region muScreen start=+ \.+ end=+\.$\|$+
highlight link muScreen muString
2016-10-22 23:56:07 +00:00
" Mu literals
syntax match muLiteral %[^ ]\+:literal/[^ ,]*\|[^ ]\+:literal\>%
syntax match muLiteral %\<[0-9-]\?[0-9]\+/[^ ,]*%
syntax match muLiteral % [0-9-]\?[0-9]\+[, ]\@=\| [0-9-]\?[0-9]\+$%
syntax match muLiteral "^\s\+[^ 0-9a-zA-Z{}$#\[\]][^ ]*\s*$"
" labels
syntax match muLiteral %[^ ]\+:label/[^ ,]*\|[^ ]\+:label\>%
" other literal types
syntax match muLiteral %[^ ]\+:type/[^ ,]*\|[^ ]\+:type\>%
syntax match muLiteral %[^ ]\+:offset/[^ ,]*\|[^ ]\+:offset\>%
syntax match muLiteral %[^ ]\+:variant/[^ ,]*\|[^ ]\+:variant\>%
syntax match muLiteral % true\(\/[^ ]*\)\?\| false\(\/[^ ]*\)\?% " literals will never be the first word in an instruction
2018-06-17 18:20:53 +00:00
syntax match muLiteral % null\(\/[^ ]*\)\?%
2015-07-31 03:56:44 +00:00
highlight link muLiteral Constant
2015-01-14 03:25:31 +00:00
2017-12-28 04:19:46 +00:00
" sources of action at a distance
syntax match muAssign "<-"
syntax match muAssign "\<raw\>"
highlight link muAssign SpecialChar
2018-07-01 04:58:55 +00:00
syntax match muGlobal %[^ ]\+:global/\?[^ ,]*% | highlight link muGlobal SpecialChar
2017-12-28 04:19:46 +00:00
2015-04-11 06:59:59 +00:00
" common keywords
2017-12-28 04:38:53 +00:00
" use regular expressions for common words that may come after '/'
2017-12-28 04:19:46 +00:00
syntax keyword muKeyword default-space local-scope
2017-12-28 04:38:53 +00:00
syntax keyword muKeyword next-input rewind-inputs load-inputs
syntax keyword muKeyword next-ingredient rewind-ingredients load-ingredients
syntax match muKeyword " input\>\| ingredient\>"
2017-12-28 04:19:46 +00:00
highlight link muKeyword Constant
syntax keyword muControl return return-if return-unless
syntax keyword muControl reply reply-if reply-unless
2017-12-28 04:38:53 +00:00
syntax keyword muControl output-if output-unless
syntax match muControl "^return\>\| return\>\|^reply\>\| reply\>\|^output\|^ output\>"
syntax keyword muControl jump-if jump-unless
syntax keyword muControl break-if break-unless
syntax keyword muControl loop-if loop-unless
syntax match muControl "^jump\>\| jump\>\|^break\>\| break\>\|^loop\>\| loop\>"
2017-12-28 04:19:46 +00:00
syntax keyword muControl start-running
syntax keyword muControl call-with-continuation-mark return-continuation-until-mark
highlight muControl ctermfg=3
2017-12-28 04:38:53 +00:00
syntax match muRecipe "->"
syntax match muRecipe "^recipe\>\|^def\>\|^before\>\|^after\>\| -> "
2018-02-22 04:49:04 +00:00
syntax keyword muRecipe recipe! def! function fn
2017-12-28 04:38:53 +00:00
highlight muRecipe ctermfg=208
2018-07-01 04:58:55 +00:00
syntax match muScenario "^scenario\>" | highlight muScenario ctermfg=34
syntax keyword muPendingScenario pending-scenario | highlight link muPendingScenario SpecialChar
2017-12-28 04:38:53 +00:00
syntax match muData "^type\>\|^container\>"
syntax keyword muData exclusive-container
highlight muData ctermfg=226
2015-01-14 03:25:31 +00:00
let &cpo = s:save_cpo