Skip to content

Commit 3e0e32c

Browse files
committed
Merge remote-tracking branch 'alexherbo2/coffee-rc'
2 parents 14256e4 + dccaaa1 commit 3e0e32c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

rc/extra/coffee.kak

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# http://coffeescript.org
22
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
33

4+
# require commenting.kak
5+
46
# Detection
57
# ‾‾‾‾‾‾‾‾‾
68

@@ -50,20 +52,23 @@ addhl -group /coffee/code regex \<(break|case|catch|class|const|continue|debugge
5052
# ‾‾‾‾‾‾‾‾
5153

5254
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+
}
5560
}
5661

5762
def -hidden _coffee_indent_on_new_line %{
5863
eval -draft -itersel %{
5964
# preserve previous line indent
60-
try %{ exec -draft <space> K <a-&> }
65+
try %{ exec -draft K <a-&> }
6166
# filter previous line
6267
try %{ exec -draft k : _coffee_filter_around_selections <ret> }
6368
# 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> }
6772
}
6873
}
6974

@@ -75,6 +80,9 @@ hook global WinSetOption filetype=coffee %{
7580

7681
hook window InsertEnd .* -group coffee-hooks _coffee_filter_around_selections
7782
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 '###:###'
7886
}
7987

8088
hook global WinSetOption filetype=(?!coffee).* %{

0 commit comments

Comments
 (0)