-
Notifications
You must be signed in to change notification settings - Fork 1
/
rum-mode.el
74 lines (63 loc) · 1.71 KB
/
rum-mode.el
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
;;; rum-mode.el --- Major mode for Rum programming language
;; Copyright 2017 The Rum Language Authors. All rights reserve
;; Use of this source code is governed by a MIT
;; license that can be found in the LICENSE file.
;; Authors: Avelino <[email protected]>
;; URL: https://github.com/rumlang/rum-mode
;; Version: 1.2
;; Keywords: rum, languages, lisp
;; Package-Requires: ((emacs "24"))
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
;; rum-mode is a major mode for editing code written in Rum
;; Language.
;;; Code:
;; all rum keywords
(defconst rum-keywords
(regexp-opt
'("package"
"breack"
"continue"
"for"
"if"
"else"
"import"
"let"
"return"
"struct"
"case"
"default"
"print"
"sprint"
"lambda") 'words))
;; all rum functions name
(defconst rum-functions
(regexp-opt
'("def") 'words))
;; all rum types name
(defconst rum-types
(regexp-opt
'("struct"
"map"
"array") 'words))
;; create the list for font-lock.
;; each category of keyword is given a particular face
(defconst rum-font-lock-keywords
(list
`(,rum-keywords . font-lock-builtin-face)
`(,rum-functions . font-lock-function-name-face)
`(,rum-types . font-lock-type-face)
`(,"\\<\\(struct\\)\\s-+\\(\\w+\\)\\>"
(1 font-lock-keyword-face)
(2 font-lock-type-face))
`(,"\\<\\(def\\)\\s-+\\(\\w+\\)\\>"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))))
;;;###autoload
(define-derived-mode rum-mode lisp-mode "rum"
"Major mode for editing rum script"
(set (make-local-variable 'font-lock-defaults) '(rum-font-lock-keywords)))
(add-to-list 'auto-mode-alist '("\\.rum\\'" . rum-mode))
(provide 'rum-mode)
;;; rum-mode.el ends here