Skip to content

Commit

Permalink
[NEW] The Ruby bundle now includes an rcodetools-backed completion co…
Browse files Browse the repository at this point in the history
…mmand on option-escape. This command is capable of very accurate completion for any accessible Ruby objects and methods, without needing to see you type it first (as TextMate's default completion requires).

git-svn-id: http://svn.textmate.org/trunk/Bundles/Ruby.tmbundle@6455 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
JEG2 committed Jan 17, 2007
1 parent 970738e commit 340c25d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions Commands/Completion: Ruby (rcodetools).tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby -w
require "#{ENV["TM_SUPPORT_PATH"]}/lib/exit_codes"
require "#{ENV["TM_SUPPORT_PATH"]}/lib/dialog"
TM_RUBY = ENV["TM_RUBY"] || "ruby"
RCODETOOLS = "#{ENV['TM_BUNDLE_SUPPORT']}/vendor/rcodetools"
command = &lt;&lt;END_COMMAND.tr("\n", " ").strip
"#{TM_RUBY}"
-I "#{RCODETOOLS}/lib"
--
"#{RCODETOOLS}/bin/rct-complete"
--line=#{ENV['TM_LINE_NUMBER']}
--column=#{ENV['TM_LINE_INDEX']}
END_COMMAND
completions = `#{command}`.to_a.map { |l| l.strip }.select { |l| l =~ /\S/ }
if completions.size == 1
selected = completions.first
elsif completions.size &gt; 1
selected = completions[Dialog.menu(completions)] rescue exit
else
TextMate.exit_show_tool_tip "No matches were found."
end
print selected.sub(/\A#{Regexp.escape(ENV['TM_CURRENT_WORD'].to_s)}/, "")
</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>~</string>
<key>name</key>
<string>Completion: Ruby (rcodetools)</string>
<key>output</key>
<string>afterSelectedText</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>47D203ED-EB9B-4653-A07B-A897800CEB76</string>
</dict>
</plist>
4 changes: 3 additions & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<string>76FCF165-54CB-4213-BC55-BD60B9C6A3EC</string>
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
<string>835FAAC6-5431-436C-998B-241F7226B99B</string>
<string>A83F68A9-F751-4BB4-AE16-56812878C16A</string>
<string>47D203ED-EB9B-4653-A07B-A897800CEB76</string>
<string>8394EDEF-87E8-11D9-A6A3-000D93589AF6</string>
<string>BE3B3E5E-733E-11D9-A833-000A95A89C98</string>
<string>66708792-62C3-11D9-B8CF-000D93589AF6</string>
Expand All @@ -25,7 +27,6 @@
<string>667081DE-62C3-11D9-B8CF-000D93589AF6</string>
<string>66708259-62C3-11D9-B8CF-000D93589AF6</string>
<string>66708052-62C3-11D9-B8CF-000D93589AF6</string>
<string>A83F68A9-F751-4BB4-AE16-56812878C16A</string>
</array>
<key>items</key>
<array>
Expand Down Expand Up @@ -576,6 +577,7 @@
<string>FD010022-E0E7-44DB-827F-33F7D9310DA2</string>
<string>AEDD6A5F-417F-4177-8589-B07518ACA9DE</string>
<string>1A7701FA-D866-498C-AD4C-7846538DB535</string>
<string>47D203ED-EB9B-4653-A07B-A897800CEB76</string>
</array>
<key>uuid</key>
<string>467B298F-6227-11D9-BFB1-000D93589AF6</string>
Expand Down

0 comments on commit 340c25d

Please sign in to comment.