about summary refs log tree commit diff stats
path: root/mu.vim
blob: d62b792f7b638bee266f45a46143813916f44af8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
" Vim syntax file
" Language:    mu
" Maintainer:  Kartik Agaram <mu@akkartik.com>
" URL:         http://github.com/akkartik/mu
" License:     public domain
"
" Copy this into your ftplugin directory, and add the following to your vimrc
" or to .vim/ftdetect/mu.vim:
"   autocmd BufReadPost,BufNewFile *.mu set filetype=mu

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 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:#
syntax match muCommentedCode "#? .*"  | highlight link muCommentedCode CommentedCode
let b:cmt_head = "#? "

syntax match muDelimiter "[{}]"  | highlight link muDelimiter Delimiter

" Mu strings are inside [ ... ] and can span multiple lines
" don't match '[' at end of line, that's usually code
syntax match muLiteral %^[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*\|[ ,]\@<=[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*%
syntax region muString start=+\[[^\]]+ end=+\]+
syntax match muString "\[\]"
highlight link muString String
" Mu syntax for representing the screen in scenarios
syntax region muScreen start=+ \.+ end=+\.$\|$+
highlight link muScreen muString

" 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
syntax match muLiteral % null\(\/[^ ]*\)\?%
highlight link muLiteral Constant

" sources of action at a distance
syntax match muAssign "<-"
syntax match muAssign "\<raw\>"
highlight link muAssign SpecialChar
syntax match muGlobal %[^ ]\+:global/\?[^ ,]*%  | highlight link muGlobal SpecialChar

" common keywords
" use regular expressions for common words that may come after '/'
syntax keyword muKeyword default-space local-scope
syntax keyword muKeyword next-input rewind-inputs load-inputs
syntax keyword muKeyword next-ingredient rewind-ingredients load-ingredients
syntax match muKeyword " input\>\| ingredient\>"
highlight link muKeyword Constant

syntax keyword muControl return return-if return-unless
syntax keyword muControl reply reply-if reply-unless
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\>"
syntax keyword muControl start-running
syntax keyword muControl call-with-continuation-mark return-continuation-until-mark
highlight muControl ctermfg=3

syntax match muRecipe "->"
syntax match muRecipe "^recipe\>\|^def\>\|^before\>\|^after\>\| -> "
syntax keyword muRecipe recipe! def! function fn
highlight muRecipe ctermfg=208

syntax match muScenario "^scenario\>"  | highlight muScenario ctermfg=34
syntax keyword muPendingScenario pending-scenario  | highlight link muPendingScenario SpecialChar
syntax match muData "^type\>\|^container\>"
syntax keyword muData exclusive-container
highlight muData ctermfg=226

let &cpo = s:save_cpo
of_on_unload(): """Called when a plugin is unloaded with the ``/plugins unload`` command """ pass def prof_on_connect(account_name, fulljid): """Called when the user connects with an account :param account_name: account name of the account used for logging in :param fulljid: the full Jabber ID (barejid and resource) of the account :type account_name: str or unicode :type fulljid: str or unicode """ pass def prof_on_disconnect(account_name, fulljid): """Called when the user disconnects an account :param account_name: account name of the account being disconnected :param fulljid: the full Jabber ID (barejid and resource) of the account :type account_name: str or unicode :type fulljid: str or unicode """ pass def prof_pre_chat_message_display(barejid, resource, message): """Called before a chat message is displayed :param barejid: Jabber ID of the message sender :param resource: resource of the message sender :param message: the received message :type barejid: str or unicode :type resource: str or unicode :type message: str or unicode :return: the new message to display, or ``None`` to preserve the original message :rtype: str or unicode """ pass def prof_post_chat_message_display(barejid, resource, message): """Called after a chat message is displayed :param barejid: Jabber ID of the message sender :param resource: resource of the message sender :param message: the received message :type barejid: str or unicode :type resource: str or unicode :type message: str or unicode """ pass def prof_pre_chat_message_send(barejid, message): """Called before a chat message is sent :param barejid: Jabber ID of the message recipient :param message: the message to be sent :type barejid: str or unicode :type message: str or unicode :return: the modified or original message to send, or ``None`` to cancel sending of the message :rtype: str or unicode """ pass def prof_post_chat_message_send(barejid, message): """Called after a chat message has been sent :param barejid: Jabber ID of the message recipient :param message: the sent message :type barejid: str or unicode :type message: str or unicode """ pass def prof_pre_room_message_display(barejid, nick, message): """Called before a chat room message is displayed :param barejid: Jabber ID of the room :param nick: nickname of message sender :param message: the received message :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode :return: the new message to display, or ``None`` to preserve the original message :rtype: str or unicode """ pass def prof_post_room_message_display(barejid, nick, message): """Called after a chat room message is displayed :param barejid: Jabber ID of the room :param nick: nickname of the message sender :param message: the received message :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode """ pass def prof_pre_room_message_send(barejid, message): """Called before a chat room message is sent :param barejid: Jabber ID of the room :param message: the message to be sent :type barejid: str or unicode :type message: str or unicode :return: the modified or original message to send, or ``None`` to cancel sending of the message :rtype: str or unicode """ pass def prof_post_room_message_send(barejid, message): """Called after a chat room message has been sent :param barejid: Jabber ID of the room :param message: the sent message :type barejid: str or unicode :type message: str or unicode """ pass def prof_on_room_history_message(barejid, nick, message, timestamp): """Called when the server sends a chat room history message :param barejid: Jabber ID of the room :param nick: nickname of the message sender :param message: the message to be sent :param timestamp: time the message was originally sent to the room, in ISO8601 format :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode :type timestamp: str or unicode """ pass def prof_pre_priv_message_display(barejid, nick, message): """Called before a private chat room message is displayed :param barejid: Jabber ID of the room :param nick: nickname of message sender :param message: the received message :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode :return: the new message to display, or ``None`` to preserve the original message :rtype: str or unicode """ pass def prof_post_priv_message_display(barejid, nick, message): """Called after a private chat room message is displayed :param barejid: Jabber ID of the room :param nick: nickname of the message sender :param message: the received message :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode """ pass def prof_pre_priv_message_send(barejid, nick, message): """Called before a private chat room message is sent :param barejid: Jabber ID of the room :param nick: nickname of message recipient :param message: the message to be sent :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode :return: the modified or original message to send, or ``None`` to cancel sending of the message :rtype: str or unicode """ pass def prof_post_priv_message_send(barejid, nick, message): """Called after a private chat room message has been sent :param barejid: Jabber ID of the room :param nick: nickname of the message recipient :param message: the sent message :type barejid: str or unicode :type nick: str or unicode :type message: str or unicode """ pass def prof_on_message_stanza_send(stanza): """Called before an XMPP message stanza is sent :param stanza: The stanza to send :type stanza: str or unicode :return: The new stanza to send, or ``None`` to preserve the original stanza :rtype: str or unicode """ pass def prof_on_message_stanza_receive(stanza): """Called when an XMPP message stanza is received :param stanza: The stanza received :type stanza: str or unicode :return: ``True`` if Profanity should continue to process the message stanza, ``False`` otherwise :rtype: boolean """ pass def prof_on_presence_stanza_send(stanza): """Called before an XMPP presence stanza is sent :param stanza: The stanza to send :type stanza: str or unicode :return: The new stanza to send, or ``None`` to preserve the original stanza :rtype: str or unicode """ pass def prof_on_presence_stanza_receive(stanza): """Called when an XMPP presence stanza is received :param stanza: The stanza received :type stanza: str or unicode :return: ``True`` if Profanity should continue to process the presence stanza, ``False`` otherwise :rtype: boolean """ pass def prof_on_iq_stanza_send(stanza): """Called before an XMPP iq stanza is sent :param stanza: The stanza to send :type stanza: str or unicode :return: The new stanza to send, or ``None`` to preserve the original stanza :rtype: str or unicode """ pass def prof_on_iq_stanza_receive(stanza): """Called when an XMPP iq stanza is received :param stanza: The stanza received :type stanza: str or unicode :return: ``True`` if Profanity should continue to process the iq stanza, ``False`` otherwise :rtype: boolean """ pass def prof_on_contact_offline(barejid, resource, status): """Called when a contact goes offline :param barejid: Jabber ID of the contact :param resource: the resource being disconnected :param status: the status message received with the offline presence, or ``None`` :type barejid: str or unicode :type resource: str or unicode :type status: str or unicode """ pass def prof_on_contact_presence(barejid, resource, presence, status, priority): """Called when a presence notification is received from a contact :param barejid: Jabber ID of the contact :param resource: the resource being disconnected :param presence: presence of the contact, one of ``"chat"``, ``"online"``, ``"away"``, ``"xa"`` or ``"dnd"`` :param status: the status message received with the presence, or ``None`` :param priority: the priority associated with the resource :type barejid: str or unicode :type resource: str or unicode :type presence: str or unicode :type status: str or unicode :type priority: int """ pass def prof_on_chat_win_focus(barejid): """Called when a chat window is focused :param barejid: Jabber ID of the chat window recipient :type barejid: str or unicode """ pass def prof_on_room_win_focus(barejid): """Called when a chat room window is focused :param barejid: Jabber ID of the room :type barejid: str or unicode """ pass