/
Reformat Comment.tmCommand
57 lines (52 loc) · 1.49 KB
/
Reformat Comment.tmCommand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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 ruby18
$LOAD_PATH << "#{ENV["TM_SUPPORT_PATH"]}/lib"
require "escape"
require "exit_codes"
ctext = STDIN.read
if ctext =~ /^\s*(.[^\s\w\\]*\s*)/
cstring = $1
else
TextMate.exit_show_tool_tip("Unable to determine comment character.")
end
flags = %Q{-p "#{cstring}"}
flags += " --retabify" unless ENV["TM_SOFT_TABS"] == "YES"
flags += " -c #{ENV['TM_COLUMNS'].nil? ? 80 : ENV['TM_COLUMNS']}"
command = "ruby18 #{e_sh(ENV["TM_BUNDLE_SUPPORT"])}/bin/rubywrap.rb #{flags}"
text = open("| #{command}", "r+") do |wrapper|
wrapper << ctext
wrapper.close_write
wrapper.read
end
print e_sn(text)
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^q</string>
<key>name</key>
<string>Reformat Comment</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>snippet</string>
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>punctuation.whitespace.comment.leading | comment.line</string>
<key>uuid</key>
<string>F20AD964-3C68-4940-91B1-8A99B8E2A375</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>