mu/editor/mu.vim

93 lines
2.9 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:
highlight link CommentedCode Comment
highlight link SalientComment Comment
highlight link muFunction Identifier
highlight link muTest Identifier
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-08 05:00:38 +00:00
syntax match muComment /#\( \.\|? \)\@!.*/ | highlight link muComment Comment
2020-10-05 04:24:46 +00:00
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
syntax keyword muAssign error error-stream
highlight link muAssign Special
2020-02-28 19:19:53 +00:00
" common keywords
2020-11-01 03:37:36 +00:00
syntax match muControl "\<return\>\|\<return-if[^ ]*\>"
2020-02-28 19:19:53 +00:00
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\>"
2021-06-05 03:50:46 +00:00
syntax match muData "\<xmm[0-7]\>"
2020-02-28 19:19:53 +00:00
highlight link muData Constant
" Some hacky colors for a light background.
" TODO: They should really be theme-dependent. Use tools/regs.mu when tweaking them.
" eax is so common that it's not worth highlighting
2021-06-05 03:50:46 +00:00
syntax match muRegEcx "\<ecx\>"
highlight muRegEcx ctermfg=88
2021-06-05 03:50:46 +00:00
syntax match muRegEdx "\<edx\>"
highlight muRegEdx ctermfg=130
2021-06-05 03:50:46 +00:00
syntax match muRegEbx "\<ebx\>"
highlight muRegEbx ctermfg=57
2021-06-05 03:50:46 +00:00
syntax match muRegEsi "\<esi\>"
highlight muRegEsi ctermfg=25
2021-06-05 03:50:46 +00:00
syntax match muRegEdi "\<edi\>"
highlight muRegEdi ctermfg=34
2021-06-05 03:50:46 +00:00
2020-02-28 19:19:53 +00:00
let &cpo = s:save_cpo