-
Notifications
You must be signed in to change notification settings - Fork 0
/
poly-web-components.el
72 lines (56 loc) · 2.02 KB
/
poly-web-components.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
;; CSS-in-JS mode for use in ${} blocks in CSS template strings
;; (define-hostmode poly-css-in-js-hostmode
;; :mode 'scss-mode)
;; (define-innermode poly-css-in-js-innermode
;; :mode 'js-mode
;; :head-matcher "\\(\\${([^)]+) => \\(`[^`]+`\\|[^}]+\\)}\\)"
;; :tail-matcher ";"
;; :tail-mode 'host)
;; (define-polymode poly-css-in-js-mode
;; :hostmode 'poly-css-in-js-hostmode
;; :innermodes '(poly-css-in-js-innermode))
;; The main Web Components modes
(define-hostmode poly-web-components-hostmode
:mode 'js-mode)
(define-hostmode poly-ts-web-components-hostmode
:mode 'typescript-mode)
(define-innermode poly-web-components-css-innermode
:mode 'css-mode
:head-matcher "\\(styled.\\w+\\|css\\|keyframes\\)\\(<\\(.\\|\n\\)*?>\\)?`"
:tail-matcher "`[;,\n]"
:allow-nested nil
:head-mode 'host
:tail-mode 'host
:body-indent-offset 2)
(define-innermode poly-web-components-ts-innermode
:mode 'typescript-mode
:can-overlap t
:allow-nested nil
:head-matcher "\\${"
:tail-matcher "};")
;; (define-innermode poly-web-components-js-in-template-innermode
;; :mode 'typescript-mode
;; ;; :head-matcher "\\(\\${([^)]+) => \\(?:`[^`]+`\\|[^}]+\\)}\\)"
;; :head-matcher "\\${"
;; :tail-matcher "};")
;; (define-innermode poly-web-components-css-in-js-innermode
;; :mode 'poly-css-in-js-mode
;; :head-matcher "\\(styled.\\w+\\|css\\|keyframes\\)\\(<\\(.\\|\n\\)*?>\\)?`"
;; :tail-matcher "`"
;; :head-mode 'host
;; :tail-mode 'host)
(define-innermode poly-web-components-html-innermode
:mode 'html-mode
:head-matcher "\\(html\\( ?= ?\\)?`\\|\\.innerHTML\s*=\s*`\\)"
:tail-matcher "`"
:head-mode 'host
:tail-mode 'host)
(define-polymode poly-web-components-mode
:hostmode 'pm-host/js
:innermodes '(poly-web-components-css-innermode
poly-web-components-html-innermode))
(define-polymode poly-ts-web-components-mode
:hostmode 'poly-ts-web-components-hostmode
:innermodes '(
poly-web-components-css-innermode
poly-web-components-html-innermode))