File tree Expand file tree Collapse file tree 5 files changed +55
-1
lines changed Expand file tree Collapse file tree 5 files changed +55
-1
lines changed Original file line number Diff line number Diff line change 1212 { "caption" : " Create Package…" ,
1313 "command" : " packagedev_create_package" },
1414
15+ { "caption" : " Open Package…" ,
16+ "command" : " packagedev_open_package" },
17+
1518 { "caption" : " -" },
1619
1720 { "caption" : " New Syntax Definition…" ,
Original file line number Diff line number Diff line change 1616 "command" : " packagedev_create_package" ,
1717 },
1818
19+ { "caption" : " PackageDev: Open Package" ,
20+ "command" : " packagedev_open_package" ,
21+ },
22+
1923 // Snippets
2024 { "caption" : " PackageDev: New Raw Snippet" ,
2125 "command" : " packagedev_new_resource" ,
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ Detailed documentation is available [at the repository's wiki][wiki].
8787 snippets are available with the trigger ` e ` and ` ee `
8888 for a short and a long entry, respectively.
8989
90- - Commands to create a package
90+ - Commands to create (or open) a package
9191 and various resource files with standard templates.
9292
9393- Checking for unknown settings keys.
Original file line number Diff line number Diff line change 55from .create_package import * # noqa
66from .file_conversion import * # noqa
77from .new_resource_file import * # noqa
8+ from .open_package import * # noqa
89from .settings import * # noqa
910from .snippet_dev import * # noqa
1011from .syntax_dev import * # noqa
Original file line number Diff line number Diff line change 1+ import glob
2+ import os
3+
4+ import sublime
5+ import sublime_plugin
6+
7+ from .create_package import _open_folder_in_st , _is_override_package
8+
9+ __all__ = ('PackagedevOpenPackageCommand' ,)
10+
11+ OVERRIDE_SUFFIX = " [*Override*]"
12+
13+
14+ def _list_normal_packages ():
15+ pkgspath = sublime .packages_path ()
16+ folders = glob .glob (os .path .join (pkgspath , "*/" , "" ))
17+ names = (os .path .basename (fold .strip ("\\ /" )) for fold in folders )
18+ for name in names :
19+ yield (name , _is_override_package (name ))
20+
21+
22+ class NameInputHandler (sublime_plugin .ListInputHandler ):
23+
24+ def placeholder (self ):
25+ return "Package"
26+
27+ def list_items (self ):
28+ packages = list (sorted (_list_normal_packages ()))
29+ print (packages )
30+ items = [name + (OVERRIDE_SUFFIX if override else "" )
31+ for name , override in packages ]
32+ return items
33+
34+
35+ class PackagedevOpenPackageCommand (sublime_plugin .WindowCommand ):
36+
37+ def input (self , args ):
38+ return NameInputHandler ()
39+
40+ def run (self , name ):
41+ if not name :
42+ return
43+ name = name .split (OVERRIDE_SUFFIX )[0 ]
44+ path = os .path .join (sublime .packages_path (), name )
45+ # TODO find a .sublime-project file and open that instead?
46+ _open_folder_in_st (path )
You can’t perform that action at this time.
0 commit comments