Browse files

Autocomplete Routes. => routesrc + <tab>

Does anyone have a better suggestion for the tab trigger?
  • Loading branch information...
1 parent 075e82c commit cb7e763a819e6cd014bdd084a28528eddab401fb @carlosbrando carlosbrando committed May 28, 2010
Showing with 41 additions and 0 deletions.
  1. +28 −0 Commands/Autocomplete Routes.tmCommand
  2. +10 −0 Support/bin/routes_auto_complete.rb
  3. +3 −0 info.plist
View
28 Commands/Autocomplete Routes.tmCommand
@@ -0,0 +1,28 @@
+<?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 bash
+. "$TM_BUNDLE_SUPPORT/lib/rvm/rvm_textmate"
+
+RUBYLIB="$TM_BUNDLE_SUPPORT/lib:$RUBYLIB"
+"${TM_RUBY:=ruby}" -- "${TM_BUNDLE_SUPPORT}/bin/routes_auto_complete.rb"</string>
+ <key>fallbackInput</key>
+ <string>word</string>
+ <key>input</key>
+ <string>selection</string>
+ <key>name</key>
+ <string>Autocomplete Routes</string>
+ <key>output</key>
+ <string>replaceSelectedText</string>
+ <key>scope</key>
+ <string>source.ruby.rails</string>
+ <key>tabTrigger</key>
+ <string>routesrc</string>
+ <key>uuid</key>
+ <string>0742F232-38ED-4C52-AD68-1858F0F2C601</string>
+</dict>
+</plist>
View
10 Support/bin/routes_auto_complete.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+require File.join(ENV['TM_SUPPORT_PATH'], 'lib', 'ui.rb')
+require File.join(ENV['TM_PROJECT_DIRECTORY'], 'config', 'environment')
+
+routes = ActionController::Routing::Routes.named_routes.routes.keys.map do |route|
+ %w(_path _url).map { |extension| route.to_s + extension } if route != :rails_info_properties
+end
+
+TextMate::UI.complete(routes.flatten.compact.sort, :extra_chars => "_")
View
3 info.plist
@@ -411,6 +411,8 @@
<dict>
<key>items</key>
<array>
+ <string>0742F232-38ED-4C52-AD68-1858F0F2C601</string>
+ <string>------------------------------------</string>
<string>856B8A7A-86FA-4424-B4D9-3D57D5C3E590</string>
<string>------------------------------------</string>
<string>91C543BF-7BD8-4E3A-B493-AE572C5472A0</string>
@@ -959,6 +961,7 @@
<string>675DD92F-42F1-4B55-B56A-5D4ABC1375C4</string>
<string>5C773E3D-436E-4A28-8399-859CE41E504F</string>
<string>CF489B31-5DD2-4B83-B503-AD3ECF7BDEB7</string>
+ <string>0742F232-38ED-4C52-AD68-1858F0F2C601</string>
<string>88047A77-B889-4F47-892D-4C3EBA98D968</string>
</array>
<key>uuid</key>

0 comments on commit cb7e763

Please sign in to comment.