Hey,
One issue I seem to struggle a lot with in Sublime is running builds and managing their processes. For simple stuff, build systems work fine. It gets problematic when I need to run multiple processes at once (e.g. server and clients).
What I always end up doing is not using sublime for builds at all, and just alt+tabbing into a terminal window to manage all of that externally. This is always a pain that I thought I’d just have to live with for not using a full IDE.
…but then I learned about Jetbrains Fleet and played around with it. While I don’t expect it to break my ST addiction, I found that it actually has a really simple and elegant solution to this problem that would work well for most projects.
Basically, you just define the tasks you want to run declaratively in a json file in your project folder, such as:
{
"configurations": [
{
"type": "command",
"allowParallelRun": false,
"name": "Compile Server",
"program": "cmake",
"args": ["--build", "build/linux", "--target", "server"],
},
{
"type": "command",
"allowParallelRun": false,
"dependsOn": ["Compile Server"],
"name": "Run Server",
"program": "build/linux/server",
"args": ["--listen-port=1234"],
},
{
"type": "command",
"allowParallelRun": false,
"name": "Compile Client",
"program": "cmake",
"args": ["--build", "build/linux", "--target", "client"],
},
{
"type": "command",
"allowParallelRun": true,
"dependsOn": ["Compile Client"],
"name": "Run Client",
"program": "build/linux/client",
"args": ["--server-port=1234"],
},
]
}
Note how you can declare dependencies between tasks, so that e.g. “Run Server” will automatically run “Build Server”, and will abort if the build failed. Also, the allowParallelRun
attribute lets you control which tasks can be run simultaneously. Since it’s false for the server above, trying to run that task while it’s already running will display a prompt telling you that it needs to be killed first.
Then, when you press the run button in the UI/activate the keyboard shortcut, you get a quick panel-like thing that asks you to pick a run configuration:
Then, you get a dedicated panel for managing these tasks, including the ability to kill/restart them, and to see their output in dedicated tabs:
This is conceptually pretty simple, but I’m not sure this would be easy to implement as a ST plugin. The UI at least seems like it’d be hard, and might involve some complicated hacks to implement. The (amazing) debugger plugin goes to great lengths to implement a fancy UI within the limitations of ST, and I suspect something similar would be needed to accomplish this.
Or maybe there’s a better way to deal with this problem in ST that I’m not aware of? I’d be curious to learn about alternative workflows people are using.