Skip to content

Instantly share code, notes, and snippets.

@jarib
Created September 10, 2009 18:15
Show Gist options
  • Save jarib/184706 to your computer and use it in GitHub Desktop.
Save jarib/184706 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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
require ENV["TM_BUNDLE_SUPPORT"] + "/method_completer"
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^ </string>
<key>name</key>
<string>Complete method</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>5AB8CDA4-9DAB-4ED1-9C54-DCF39D574CA1</string>
</dict>
</plist>
# require "rubygems"
# require "ferret"
# require "pp"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
#
# txt = STDIN.read
# query = txt[/@site\.([\w.]+)/, 1]
# index = Ferret::Index::Index.new(:path => "#{ENV['TM_PROJECT_DIRECTORY']}/.completion-index")
#
# choices = []
# index.search_each(%{key:#{query}*}) do |id, score|
# key = index[id][:key].sub(query, '')
# choices << {'display' => key, 'insert' => key} unless key.empty?
# end
#
# File.open("/tmp/completion_log", "w") do |file|
# file.puts({:query => query, :choices => choices}.pretty_inspect)
# file.puts "="*80
# end
choices = [{'display' => "foo", "insert" => "bar"}]
TextMate::UI.complete(choices) do |choice|
File.open("/tmp/completion_log", "w") { |file| file << "in block\n" }
choice['insert']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment