Generally speaking, no; the list of files that are available in the side bar isn’t available via the API. To gather it you would need to manually query the contents of the folders in the side bar (and apply any include/exclude patterns present in the project) to crawl them yourself.
If you just want to know when the list of folders is modified (i.e. someone added or removed one from the project), that’s possible in recent builds. That could be your trigger to do a re-scan of said folders so you can detect if the list of files is different.
In build 4050, the on_load_project
event was added, which triggers whenever a project is loaded. That includes when one is initially populated into a window as well as when the project file is modified.
This doesn’t apply to windows with anonymous project data however; only windows that have a sublime-project
associated with them.
import sublime
import sublime_plugin
class TestListener(sublime_plugin.EventListener):
def on_load_project(self, window):
print('Project loaded in %s' % str(window))
print(window.folders())