3 " Maintainer: Kartik Agaram <mu@akkartik.com>
4 " URL: http://github.com/akkartik/mu
5 " License: public domain
7 " Copy this file into your ftplugin directory, and add the following to your
8 " vimrc or to .vim/ftdetect/mu.vim:
9 " autocmd BufReadPost,BufNewFile *.mu set filetype=mu
11 " Some highlight groups you might want to select colors for in your vimrc:
12 highlight link CommentedCode Comment
13 highlight link SalientComment Comment
14 highlight link muFunction Identifier
15 highlight link muTest Identifier
20 " todo: why does this periodically lose syntax, like on file reload?
23 "? if exists("b:syntax")
26 "? let b:syntax = "mu"
28 setlocal iskeyword=@,48-57,?,!,_,$,-
29 setlocal formatoptions-=t " Mu programs have long lines
30 setlocal formatoptions+=c " but comments should still wrap
32 syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment
33 syntax match muComment /#\( \.\|? \)\@!.*/ | highlight link muComment Comment
34 syntax match muS1Comment /# \..*/ | highlight link muS1Comment Comment
35 syntax match muS2Comment /# \. \..*/ | highlight link muS2Comment Comment
38 syntax match muCommentedCode "#? .*" | highlight link muCommentedCode CommentedCode
39 let b:cmt_head = "#? "
41 syntax match muDelimiter "[{}]" | highlight link muDelimiter Delimiter
44 syntax match muLiteral %\<-\?[0-9][0-9A-Fa-f]*\>%
45 syntax match muLiteral %\<-\?0x[0-9A-Fa-f]\+\>%
46 syntax match muLiteral %"[^"]*"%
47 highlight link muLiteral Constant
48 syntax match muError %\<[0-9][0-9A-Fa-f]*[^0-9A-Fa-f]\>%
49 highlight link muError Error
51 " sources of action at a distance
52 syntax match muAssign "<-"
53 highlight link muAssign SpecialChar
54 syntax keyword muAssign error error-stream
55 highlight link muAssign Special
58 syntax match muControl "\<return\>\|\<return-if[^ ]*\>"
59 syntax match muControl "\<jump\>\|\<jump-if[^ ]*"
60 syntax match muControl "\<break\>\|\<break-if[^ ]*"
61 syntax match muControl "\<loop\>\|\<loop-if[^ ]*"
62 highlight link muControl PreProc
64 syntax match muKeyword " -> "
65 syntax keyword muKeyword fn sig type var
66 highlight link muKeyword PreProc
68 syntax match muFunction "\(fn\s\+\)\@<=\(\S\+\)"
69 highlight link muFunction Identifier
71 syntax match muTest "\(fn\s\+\)\@<=\(test-\S\+\)"
72 highlight link muTest Identifier
74 syntax match muData "^type\>"
75 syntax match muData "\<xmm[0-7]\>"
76 highlight link muData Constant
78 " Some hacky colors for a light background.
79 " TODO: They should really be theme-dependent. Use tools/regs.mu when tweaking them.
80 " eax is so common that it's not worth highlighting
81 syntax match muRegEcx "\<ecx\>"
82 highlight muRegEcx ctermfg=88
83 syntax match muRegEdx "\<edx\>"
84 highlight muRegEdx ctermfg=130
85 syntax match muRegEbx "\<ebx\>"
86 highlight muRegEbx ctermfg=57
87 syntax match muRegEsi "\<esi\>"
88 highlight muRegEsi ctermfg=25
89 syntax match muRegEdi "\<edi\>"
90 highlight muRegEdi ctermfg=34