-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathview_resource.py
34 lines (25 loc) · 955 Bytes
/
view_resource.py
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
import sublime
import sublime_plugin
class ResourceNameInputHandler(sublime_plugin.ListInputHandler):
def name(self):
return "name"
def placeholder(self):
return "Name"
def list_items(self):
settings = sublime.load_settings("Preferences.sublime-settings")
exclude = set(f + '/' for f in settings.get("folder_exclude_patterns", []))
PACKAGES = "Packages/"
start = len(PACKAGES)
return [
f[start:] for f in sublime.find_resources('')
if f.startswith(PACKAGES)
and not f.endswith('.sublime-package')
and not any(fe in f for fe in exclude)
]
class ViewResourceCommand(sublime_plugin.WindowCommand):
def run(self, name):
self.window.run_command("open_file", {"file": "${packages}/" + name})
def input(self, args):
if "name" not in args:
return ResourceNameInputHandler()
return None