Hello! I’m trying to write a plugin that will take a directory location and a project name and create a new project at that destination (if the project doesn’t already exist) and switch to it. The problem is that I couldn’t find much documentation on the project APIs, so I don’t know how to create a project in such a way that it would be added to the recent projects tab, and I don’t know how to switch to the project based on the file name. Could someone give me a hand/point me in the right direction? Thanks!
Create and Switch to Project from Plugin
Run sublime.log_commands(True) in the console, and it’ll print out everything you do. Then you can see what commands are called when you perform different actions.
The problem is that this doesn’t really help me find the commands I need. The main menu items are “Open Project”, “Switch Project”, “Save Project As”, and “Open Recent [project]”, all of which prompt for user input. If there was a way to see the internals of those functions, so I could see what they do with that user input, that would be great; otherwise, they’re not very helpful to me.
Unfortunately there isn’t an API to create or open a project that doesn’t ask for user input. Creating a project isn’t too hard, it’s just a json file. To open it, people have written plugins that will shell out and execute the sublime executable which will open a new window. Take a look at the SideBarEnhancements plugin which does this (github.com/titoBouzout/SideBarE … r.py#L1447).