Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
noniq committed Oct 10, 2019
2 parents 5f46806 + 089e0ce commit 66140d3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 77 deletions.
78 changes: 40 additions & 38 deletions Commands/Open Require.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,65 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
<string>#!/usr/bin/env ruby
require 'shellwords'
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate.rb"
def require_paths_for_gem(path)
begin
if gem_spec = Gem::Specification.find_by_name(path.tr('/', '-'))
return gem_spec.full_require_paths
end
rescue Gem::MissingSpecError =&gt; e
end
REQUIRE_RE = /^\s*(?:require|load)\s*(['"])([^'"#]+?)(?:\.rb)?\1[ \t]*$/
Dir.chdir(ENV['TM_DIRECTORY']) if ENV.has_key?('TM_DIRECTORY')
gems_installed = begin
require 'rubygems'
true
rescue LoadError
false
end
if path.include?('/')
require_paths_for_gem(File.dirname(path))
end
end
requires = if ENV['TM_CURRENT_LINE'].to_s =~ REQUIRE_RE
["#{$2}.rb"]
else
$stdin.read.scan(REQUIRE_RE).map { |_, path| "#{path}.rb" }
end
abort 'No includes found.' if requires.empty?
if ENV['TM_CURRENT_LINE'] =~ /^\s*(?:require(_relative)?|load)\s*(['"])(.+?)(?:\.rb)?\2(?:\s+|$)?/
name, file = $3, "#$3.rb"
file = if requires.size &gt; 1
choice = TextMate::UI.menu(requires) or exit
requires[choice]
else
requires.pop
end
dir = $LOAD_PATH.find { |dir| File.exist? File.join(dir, file) }
if not dir and gems_installed and gem_spec = Gem::GemPathSearcher.new.find(file)
dir = File.join(gem_spec.full_gem_path, gem_spec.require_path)
end
if $1 == '_relative'
search_paths = [ ENV['TM_DIRECTORY'] ]
elsif paths = require_paths_for_gem(name)
search_paths = $LOAD_PATH + paths
else
search_paths = $LOAD_PATH
end
if file and dir
dir.sub!(%r{\A\.(?=/|\z)}, ENV['TM_DIRECTORY']) if ENV['TM_DIRECTORY']
file_path = File.join(dir, file)
# puts file_path
TextMate.go_to :file =&gt; file_path
exit
if path = search_paths.map { |path| File.join(path, file) }.find { |path| File.exist?(path) }
%x{ "$TM_MATE" #{path.shellescape} }
else
puts "Unable to locate ‘#{file}’. Locations searched:"
puts search_paths.map { |path| "• #{path}" }.join("\n")
end
else
puts "File not found: #{file}"
puts "No require, require_relative, or"
puts "load statement found in current line."
end
</string>
<key>fallbackInput</key>
<string>document</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@D</string>
<key>name</key>
<string>Open Require</string>
<key>output</key>
<string>showAsTooltip</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>toolTip</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>8646378E-91F5-4771-AC7C-43FC49A93576</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
7 changes: 7 additions & 0 deletions Preferences/Folding.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<string>source.ruby -string.unquoted.heredoc</string>
<key>settings</key>
<dict>
<key>foldingIndentedBlockStart</key>
<string>(?x)
^ \s+ when \s
( .* (\s then | :) \s* (\#.*)? $
| (?! .*? (\s then | :) \s+ [^#\s] )
)
</string>
<key>foldingStartMarker</key>
<string>(?x)^
(\s*+
Expand Down
2 changes: 1 addition & 1 deletion Support/bin/linked_ri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require "erb"
include ERB::Util

RI_EXE = [ ENV['TM_RUBY_RI'], 'qri', '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ri' ].find { |cmd| !cmd.to_s.empty? && (File.executable?(cmd) || ENV['PATH'].split(':').any? { |dir| File.executable? File.join(dir, cmd) }) ? cmd : false }
RI_EXE = [ ENV['TM_RUBY_RI'], 'qri', 'ri' ].find { |cmd| !cmd.to_s.empty? && (File.executable?(cmd) || ENV['PATH'].split(':').any? { |dir| File.executable? File.join(dir, cmd) }) ? cmd : false }

term = ARGV.shift

Expand Down
2 changes: 1 addition & 1 deletion Support/bin/ri_to_html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/htmloutput.rb"
require "shellwords"

RI_EXE = '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ri'
RI_EXE = [ ENV['TM_RUBY_RI'], 'qri', 'ri' ].find { |cmd| !cmd.to_s.empty? && (File.executable?(cmd) || ENV['PATH'].split(':').any? { |dir| File.executable? File.join(dir, cmd) }) ? cmd : false }

def make_link(text, term)
"<a href='javascript:lookup(&quot;#{term.shellescape}&quot;)' title='Lookup ‘#{term}’'>#{text}</a>"
Expand Down
75 changes: 38 additions & 37 deletions Syntaxes/Ruby.plist
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<string>Snapfile</string>
<string>Gymfile</string>
<string>jb</string>
<string>Podfile</string>
</array>
<key>firstLineMatch</key>
<string>(?x)
Expand Down Expand Up @@ -269,10 +270,46 @@
</dict>
<dict>
<key>match</key>
<string>\b(__(FILE|LINE)__)\b(?![?!])</string>
<string>\b(__(dir|FILE|LINE)__)\b(?![?!])</string>
<key>name</key>
<string>variable.language.ruby</string>
</dict>
<dict>
<key>begin</key>
<string>^__END__\n</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>string.unquoted.program-block.ruby</string>
</dict>
</dict>
<key>comment</key>
<string>__END__ marker</string>
<key>contentName</key>
<string>text.plain</string>
<key>end</key>
<string>(?=not)impossible</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(?=&lt;?xml|&lt;(?i:html\b)|!DOCTYPE (?i:html\b))</string>
<key>end</key>
<string>(?=not)impossible</string>
<key>name</key>
<string>text.html.embedded.ruby</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>text.html.basic</string>
</dict>
</array>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>\b(self)\b(?![?!])</string>
Expand Down Expand Up @@ -1049,42 +1086,6 @@
<key>name</key>
<string>constant.numeric.ruby</string>
</dict>
<dict>
<key>begin</key>
<string>^__END__\n</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>string.unquoted.program-block.ruby</string>
</dict>
</dict>
<key>comment</key>
<string>__END__ marker</string>
<key>contentName</key>
<string>text.plain</string>
<key>end</key>
<string>(?=not)impossible</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(?=&lt;?xml|&lt;(?i:html\b)|!DOCTYPE (?i:html\b))</string>
<key>end</key>
<string>(?=not)impossible</string>
<key>name</key>
<string>text.html.embedded.ruby</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>text.html.basic</string>
</dict>
</array>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?=(?&gt;&lt;&lt;[-~]("?)((?:[_\w]+_|)HTML)\b\1))</string>
Expand Down

0 comments on commit 66140d3

Please sign in to comment.