Skip to content

Commit 5fb621e

Browse files
committed
Convert Run command to use Executor
This adds many features such as being able to run unsaved files, improving command output and displays the version number of scala. Drops the use of SCALA_HOME in favor of TM_SCALA using requiredCommands.
1 parent 50552c4 commit 5fb621e

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

Commands/Run as script.tmCommand

+21-22
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,15 @@
33
<plist version="1.0">
44
<dict>
55
<key>beforeRunningCommand</key>
6-
<string>nop</string>
6+
<string>saveModifiedFiles</string>
77
<key>command</key>
8-
<string>#!/usr/bin/env ruby18 -wKU
9-
10-
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate.rb'
11-
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/htmloutput"
12-
13-
TextMate.require_env_var("SCALA_HOME", "Please set the SCALA_HOME shell variable to the root of your scala installation. For me this is /Users/Mads/dev/programming_languages/scala-2.8.0.final")
14-
15-
if ENV['TM_FILEPATH'] != nil
16-
TextMate::HTMLOutput.show(
17-
:title =&gt; "Running: #{ENV['TM_FILEPATH']}",
18-
:sub_title =&gt; "") do |io|
19-
cmd = ENV['SCALA_HOME'] + "/bin/scala -nocompdaemon -howtorun:script " + "'" + ENV['TM_FILEPATH'] + "'"
20-
io &lt;&lt; "&lt;pre&gt;&lt;code&gt;"
21-
io &lt;&lt; `#{cmd}`
22-
io &lt;&lt; "&lt;/code&gt;&lt;/pre&gt;"
23-
end
24-
else
25-
puts "Please save your file first"
26-
end
27-
8+
<string>#!/usr/bin/env ruby18
289
10+
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/executor"
11+
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/save_current_document"
2912
13+
TextMate.save_if_untitled('scala')
14+
TextMate::Executor.run(ENV['TM_SCALA'], '-nocompdaemon', '-howtorun:script', ENV['TM_FILEPATH'], :version_args =&gt; ["-version"], :version_regex =&gt; /\AScala code runner version ([^\s]*).*/m)
3015
</string>
3116
<key>input</key>
3217
<string>document</string>
@@ -35,13 +20,27 @@ end
3520
<key>keyEquivalent</key>
3621
<string>@r</string>
3722
<key>name</key>
38-
<string>Run as script</string>
23+
<string>Run</string>
3924
<key>outputCaret</key>
4025
<string>afterOutput</string>
4126
<key>outputFormat</key>
4227
<string>html</string>
4328
<key>outputLocation</key>
4429
<string>newWindow</string>
30+
<key>requiredCommands</key>
31+
<array>
32+
<dict>
33+
<key>command</key>
34+
<string>scala</string>
35+
<key>locations</key>
36+
<array>
37+
<string>/usr/local/bin/scala</string>
38+
<string>/opt/local/bin/scala</string>
39+
</array>
40+
<key>variable</key>
41+
<string>TM_SCALA</string>
42+
</dict>
43+
</array>
4544
<key>scope</key>
4645
<string>source.scala</string>
4746
<key>uuid</key>

0 commit comments

Comments
 (0)