-
Notifications
You must be signed in to change notification settings - Fork 11
/
Open Included Listfile.tmCommand
50 lines (46 loc) · 1.37 KB
/
Open Included Listfile.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
<?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_SUPPORT_PATH'] + '/lib/textmate'
require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
abort "Unsaved file" unless ENV['TM_FILEPATH']
line = STDIN.read
dir = File.dirname(ENV['TM_FILEPATH'])
subdir = nil
if line =~ /ADD_SUBDIRECTORY\s*\((.+?)\)/i
subdir = $1
else
subdirs = Dir[dir + "/*/CMakeLists.txt"].map { |p| File.basename(File.dirname(p)) }.sort
abort "No listfile found in subdirectories" if subdirs.empty?
choice = TextMate::UI.menu(subdirs)
abort "Cancelled" unless choice
subdir = subdirs[choice]
end
if subdir
file = subdir + "/CMakeLists.txt"
path = File.join(dir, file)
abort "The file at #{file} doesn't exist" unless File.exist?(path)
TextMate.go_to(:file => path)
end
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>~@</string>
<key>name</key>
<string>Move to Subdirectory Listfile</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.cmake</string>
<key>uuid</key>
<string>6F326FB4-8DC0-49BE-B74C-7B49CFA5283F</string>
</dict>
</plist>