-
Notifications
You must be signed in to change notification settings - Fork 13
/
Completion: Inside @selector.tmCommand
60 lines (54 loc) · 1.59 KB
/
Completion: Inside @selector.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
58
59
60
<?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>bundleUUID</key>
<string>4679484F-6227-11D9-BFB1-000D93589AF6</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
require "#{ENV['TM_BUNDLE_SUPPORT']}/objc_selector_completion2"
def stripComments(line)
line.gsub(/((['"])(?:\\.|.)*?\2)|\/\*.*?\*\/|\/\/[^\n\r]*/m) do |s|
if $1
s
else
' ' * s.length()
end
end
end
def caret_position(line)
tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
if tmp > 0
caret_placement = line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
else
caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
end
end
line = STDIN.read
caret_placement = caret_position(line)
res = ObjcSelectorCompletion.new(stripComments(line) , caret_placement).print
print res</string>
<key>disableOutputAutoIndent</key>
<true/>
<key>fallbackInput</key>
<string>scope</string>
<key>hideFromUser</key>
<true/>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>~</string>
<key>name</key>
<string>Completion: Inside @selector</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>meta.selector.objc</string>
<key>uuid</key>
<string>F929835A-C9F7-4934-87BD-05FD11C4435B</string>
</dict>
</plist>