-
Notifications
You must be signed in to change notification settings - Fork 1
/
yarn-mode.el
53 lines (44 loc) · 1.55 KB
/
yarn-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
;; copyright (c) 2019 Robert Pfeiffer
;; licensed under MIT license
;; based on twee-mode.el (also MIT licensed)
;; from http://tilde.town/~cristo/twee-mode-for-emacs.html
(defvar yarn-mode-hook nil)
(add-to-list 'auto-mode-alist '("\\.yarn.txt\\'" . yarn-mode))
(defconst yarn-font-lock-keywords
(list
'("\\(\\[\\[\\)\\(.+|\\)?\\([[:alnum:]\\_-]+\\)\\(\\]\\]\\)"
(1 font-lock-keyword-face)
(2 font-lock-string-face)
(3 font-lock-function-name-face)
(4 font-lock-keyword-face))
'("^\\s-*\\(->\\)\\(.+\\)$"
(1 font-lock-keyword-face)
(2 font-lock-string-face))
'("^\\(title:\\)\\s-*\\([[:alnum:]\\_-]+\\)\\s-*$"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))
'("^\\(\\w+:\\).+$" (1 font-lock-keyword-face))
'("^\\(--*-\\)$" . font-lock-keyword-face)
'("^\\(==*=\\)$" . font-lock-keyword-face)
'("\\(<<!\\(\\w+\\)>>\\)"
. font-lock-constant-face)
'("\\(<<!\\w+\\) \\(.+?\\)\\(>>\\)"
(1 font-lock-constant-face)
(3 font-lock-constant-face))
'("\\(<<\\)\\(\\w+\\)\\(>>\\)"
(1 font-lock-comment-face)
(2 font-lock-keyword-face)
(3 font-lock-comment-face))
'("\\(<<\\)\\(\\w+\\) \\(.+?\\)\\(>>\\)"
(1 font-lock-comment-face)
(2 font-lock-keyword-face)
(4 font-lock-comment-face))))
(defun yarn-mode ()
(interactive)
(kill-all-local-variables)
(visual-line-mode)
(set (make-local-variable 'font-lock-defaults) '(yarn-font-lock-keywords))
(setq major-mode 'yarn-mode)
(setq mode-name "yarn")
(run-hooks 'yarn-mode-hook))
(provide 'yarn-mode)