-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.rb
73 lines (68 loc) · 2.6 KB
/
bundle.rb
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
73
require 'ruble'
bundle t(:bundle_name) do |bundle|
bundle.author = 'Jeremy Ashkenas, Christopher Williams'
bundle.contact_email_rot_13 = '[email protected]'
bundle.description = 'Coffeescript ruble ported from official Coffeescript Textmate bundle.'
# Folding
start_folding = /.*(->|=>)\s*$|.*[\[{]\s*$/
end_folding = /^\s*$|^\s*[}\]]\s*$/
bundle.folding['source.coffee'] = start_folding, end_folding
# Indentation
decrease_indent = /^\s*(\}|\]|else|catch|finally)$/
increase_indent = /
^\s*
(.*class
|[a-zA-Z\$_](\w|\$|:|\.)*\s*(?=\:(\s*\(.*\))?\s*((=|-)>\s*$)) # function that is not one line
|[a-zA-Z\$_](\w|\$|\.)*\s*(?=(?!\::)\:(?!(\s*\(.*\))?\s*((=|-)>))):\s*((if|while)(?!.*?then)|for|$) # assignment using multiline if,while,for
|(if|while)(?!.*?then)|for
|.*[-=]>$
|.*[\{\[]$)/x
bundle.indent['source.coffee'] = increase_indent, decrease_indent
# Fallback to use our text editor if coffeescript editor isn't available
bundle.file_types['source.coffee'] = '*.coffee', 'Cakefile'
bundle.menu t(:bundle_name) do |main_menu|
main_menu.menu t(:run) do |submenu|
submenu.command t(:run)
submenu.command t(:compile_and_display_js)
submenu.command t(:run_selected_text)
end
main_menu.menu t(:control) do |submenu|
submenu.command t(:if)
submenu.command t(:if_else)
submenu.command t(:else_if)
submenu.command t(:ternary_if)
submenu.command t(:unless)
end
main_menu.menu t(:constructs) do |submenu|
submenu.command t(:new_function)
submenu.command t(:function)
submenu.command t(:bound_function)
submenu.command t(:array_comp)
submenu.command t(:object_comp)
submenu.command t(:range_comp_exclusive)
submenu.command t(:range_comp_inclusive)
submenu.command t(:switch)
submenu.command t(:class)
submenu.command t(:try_catch)
end
main_menu.menu t(:other) do |submenu|
submenu.command t(:heredoc_double_quotes)
submenu.command t(:heredoc_single_quotes)
submenu.command t(:heredoc_comment)
submenu.command t(:align_assignments)
submenu.command t(:raw_javascript)
submenu.command t(:require)
submenu.command t(:interpolated_code)
submenu.command t(:log)
end
end
end
# Set up the Comment ENV variables for coffeescript
env "source.coffee" do |e|
e['TM_COMMENT_START'] = "# "
e['TM_COMMENT_START_2'] = "###"
e['TM_COMMENT_END_2'] = "###"
e.delete('TM_COMMENT_END')
end
# Best guess as to set of pairs...
smart_typing_pairs["source.coffee"] = ['"', '"', '(', ')', '{', '}', '[', ']', "'", "'", '`', '`']