1
1
# http://coffeescript.org
2
2
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
3
3
4
+ # require commenting.kak
5
+
4
6
# Detection
5
7
# ‾‾‾‾‾‾‾‾‾
6
8
@@ -50,20 +52,23 @@ addhl -group /coffee/code regex \<(break|case|catch|class|const|continue|debugge
50
52
# ‾‾‾‾‾‾‾‾
51
53
52
54
def -hidden _coffee_filter_around_selections %{
53
- # remove trailing white spaces
54
- try %{ exec -draft -itersel <a-x> s \h+$ <ret> d }
55
+ eval -draft -itersel %{
56
+ exec <a-x>
57
+ # remove trailing white spaces
58
+ try %{ exec -draft s \h + $ <ret> d }
59
+ }
55
60
}
56
61
57
62
def -hidden _coffee_indent_on_new_line %{
58
63
eval -draft -itersel %{
59
64
# preserve previous line indent
60
- try %{ exec -draft <space> K <a-&> }
65
+ try %{ exec -draft K <a-&> }
61
66
# filter previous line
62
67
try %{ exec -draft k : _coffee_filter_around_selections <ret> }
63
68
# copy '#' comment prefix and following white spaces
64
- try %{ exec -draft k x s ^\h*\K #\h * <ret> y j p }
65
- # indent after lines beginning with token and ending with ->
66
- try %_ exec -draft k x <a-k> ^\h* (case|catch |class|else|finally|for|function|if|switch|try |while|with)|( ->)$ <ret> j <a-gt> _
69
+ try %{ exec -draft k x s ^ \h * \K \ # \h * <ret> y j p }
70
+ # indent after start structure
71
+ try %{ exec -draft k x <a-k> ^ \h * (case|catch |class|else|finally|for|function|if|switch|try |while|with) \ b | (=| ->) $ <ret> j <a-gt> }
67
72
}
68
73
}
69
74
@@ -75,6 +80,9 @@ hook global WinSetOption filetype=coffee %{
75
80
76
81
hook window InsertEnd .* -group coffee-hooks _coffee_filter_around_selections
77
82
hook window InsertChar \n -group coffee-indent _coffee_indent_on_new_line
83
+
84
+ set window comment_line_chars ' #'
85
+ set window comment_selection_chars ' ###:###'
78
86
}
79
87
80
88
hook global WinSetOption filetype =(?!coffee).* %{
0 commit comments