@jps, @wbond: How about using the folder_exclude_patterns
in the View Package File command?
A package developer might have a couple of packages as VCS repositories installed. The list currently shows all files, even all the database files located under .git
folders or .hg
, … Maybe even some cache paths like .mypy_cache
, … .
Using the folder_exclude_patterns
could help to keep the list clean.
I also played with the file_exclude_patterns
but using fnmatch
slows down list creation drastically.
Here is an example of the file with global folder excludes applied:
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")
folder_exclude = [f + '/' for f in settings.get("folder_exclude_patterns", [])]
file_exclude = settings.get("file_exclude_patterns", [])
items = []
for f in sublime.find_resources(''):
if f.startswith("Packages/") and not any(fe in f for fe in folder_exclude):
items.append(f[len("Packages/"):])
return items
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()
else:
return None