mu/mu.vim

75 lines
2.3 KiB
VimL
Raw Normal View History

2020-02-28 19:19:53 +00:00
" Vim syntax file
" Language: mu
" Maintainer: Kartik Agaram <mu@akkartik.com>
" URL: http://github.com/akkartik/mu
" License: public domain
"
2020-05-25 05:47:09 +00:00
" Copy this file into your ftplugin directory, and add the following to your
" vimrc or to .vim/ftdetect/mu.vim:
2020-02-28 19:19:53 +00:00
" autocmd BufReadPost,BufNewFile *.mu set filetype=mu
"
" Some highlight groups you might want to select colors for in your vimrc:
" muFunction
" muTest
2020-02-28 19:19:53 +00:00
let s:save_cpo = &cpo
set cpo&vim
" 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"
setlocal iskeyword=@,48-57,?,!,_,$,-
setlocal formatoptions-=t " Mu programs have long lines
setlocal formatoptions+=c " but comments should still wrap
syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment
2020-10-05 04:24:46 +00:00
syntax match muComment /#\( \.\| - \|? \)\@!.*/ | highlight link muComment Comment
syntax match muS1Comment /# \..*/ | highlight link muS1Comment Comment
syntax match muS2Comment /# \. \..*/ | highlight link muS2Comment Comment
2020-02-28 19:19:53 +00:00
set comments+=n:#
syntax match muCommentedCode "#? .*" | highlight link muCommentedCode CommentedCode
let b:cmt_head = "#? "
syntax match muDelimiter "[{}]" | highlight link muDelimiter Delimiter
" Mu literals
2020-03-12 08:15:41 +00:00
syntax match muLiteral %\<-\?[0-9][0-9A-Fa-f]*\>%
syntax match muLiteral %\<-\?0x[0-9A-Fa-f]\+\>%
2020-03-02 16:18:08 +00:00
syntax match muLiteral %"[^"]*"%
2020-02-28 19:19:53 +00:00
highlight link muLiteral Constant
2020-07-12 04:20:06 +00:00
syntax match muError %\<[0-9][0-9A-Fa-f]*[^0-9A-Fa-f]\>%
highlight link muError Error
2020-02-28 19:19:53 +00:00
" sources of action at a distance
syntax match muAssign "<-"
highlight link muAssign SpecialChar
" common keywords
syntax match muControl "^return\>\| return\>"
syntax match muControl "\<jump\>\|\<jump-if[^ ]*"
syntax match muControl "\<break\>\|\<break-if[^ ]*"
syntax match muControl "\<loop\>\|\<loop-if[^ ]*"
2020-03-23 09:16:32 +00:00
highlight link muControl PreProc
2020-02-28 19:19:53 +00:00
2020-03-23 09:16:32 +00:00
syntax match muKeyword " -> "
2020-08-01 23:25:34 +00:00
syntax keyword muKeyword fn sig type var
2020-03-23 09:16:32 +00:00
highlight link muKeyword PreProc
syntax match muFunction "\(fn\s*\)\@<=\(\S\+\)"
highlight link muFunction Identifier
2020-03-23 09:16:32 +00:00
syntax match muTest "\(fn\s*\)\@<=\(test-\S\+\)"
highlight link muTest Identifier
2020-02-28 19:19:53 +00:00
syntax match muData "^type\>"
syntax match muData "\<eax\>\|\<ecx\>\|\<edx\>\|\<ebx\>\|\<esi\>\|\<edi\>\|\<xmm[0-7]\>"
2020-02-28 19:19:53 +00:00
highlight link muData Constant
let &cpo = s:save_cpo