summaryrefslogtreecommitdiff
path: root/rc/filetype/gjs.kak
blob: 40cdab00e0a9d0ca469f6d30f849f3a0d9db5ea0 (plain)
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
# https://github.com/ember-template-imports/ember-template-imports
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

# Detection
# ‾‾‾‾‾‾‾‾‾

hook global BufCreate .*[.](gjs) %{
    set-option buffer filetype gjs
}

hook global BufCreate .*[.](gts) %{
    set-option buffer filetype gts
}

# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾

hook global WinSetOption filetype=(gjs|gts) %{
    require-module javascript

    hook window ModeChange pop:insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent
    hook window InsertChar .* -group "%val{hook_param_capture_1}-indent" javascript-indent-on-char
    hook window InsertChar \n -group "%val{hook_param_capture_1}-insert" javascript-insert-on-new-line
    hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" javascript-indent-on-new-line

    hook -once -always window WinSetOption filetype=.* "
        remove-hooks window %val{hook_param_capture_1}-.+
    "
}

hook -group gjs-highlight global WinSetOption filetype=gjs %{
    require-module gjs
    add-highlighter window/gjs ref gjs
    hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gjs }
}

hook -group gts-highlight global WinSetOption filetype=gts %{
    require-module gts
    add-highlighter window/gts ref gts
    hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gts }
}

# Modules

provide-module gjs %{
    require-module javascript
    require-module hbs
    require-module html
    maybe-add-hbs-to-html

    add-highlighter "shared/gjs" regions
    add-highlighter "shared/gjs/" default-region ref javascript
    add-highlighter "shared/gjs/hbs" region '<template>' '</template>' ref html
}

provide-module gts %{
    require-module javascript
    require-module hbs
    require-module html
    maybe-add-hbs-to-html

    add-highlighter "shared/gts" regions
    add-highlighter "shared/gts/" default-region ref typescript
    add-highlighter "shared/gts/hbs" region '<template>' '</template>' ref html
}