eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
20.1k stars 2.5k forks source link

Provide a config file which allow some files to be already opened in Theia when the workspace/sesssion is loaded. #4263

Open vinayb21 opened 5 years ago

akosyakov commented 5 years ago

You could create a custom extension which does it.

vinayb21 commented 5 years ago

@akosyakov Is there a way to do so by changing the configuration in settings.json ?

akosyakov commented 5 years ago

no, it is not possible

Which workspace/session do you mean? Theia does not have such notions.

vinayb21 commented 5 years ago

By workspace, I meant the folder that I provided to be launched with Theia. yarn theia start /my-workspace --hostname 0.0.0.0 --port 7000

akosyakov commented 5 years ago

ok, sorry, thought you meant some cloud workspace. I know that Gitpod is capable of doing snapshot of the user layout and use it as a default on first startup: https://docs.gitpod.io/33_Sharing_and_Collaboration.html#sharing-snapshots

You could do something like that with a custom extension. To get current layout: https://github.com/theia-ide/theia/blob/5956e48a3e9bffccc6f8fc8379ebe23957f43735/packages/core/src/browser/shell/application-shell.ts#L517

ektek commented 5 years ago

I am interested in having a default layout on first startup. I see how my extension can get the layout details but am struggling to find where to load them. Any pointers would be much appreciated.

akosyakov commented 5 years ago

@ektek You can implement https://github.com/theia-ide/theia/blob/e5c229cf12ceff663d8a00fb97ac161f0922d169/packages/core/src/browser/frontend-application.ts#L70 in custom extension, from there you access views and change their state.

ektek commented 5 years ago

Thank you @akosyakov. One more related question, currently I see how to start an extension through a command. How would an extension automatically start on first load?

akosyakov commented 5 years ago

How would an extension automatically start on first load?

@ektek What extension do you mean? All native Theia extensions are loaded on startup.

ektek commented 5 years ago

@akosyakov I managed to get the layout saving and loading working, thank you! What I meant was, right now I start my extension by opening it from the menu. Is there a way to automatically start my extension on browser load?

akosyakov commented 5 years ago

Your extension can implement one of application lifecycle hooks: https://github.com/eclipse-theia/theia/blob/b7cad4848757296facef161635ee656a9be0a5b9/packages/core/src/browser/frontend-application.ts#L32-L76 For example, you can implement in onStart something which should be done for each new window. Or you can implement initializeLayout in order only do something for a new windows without previous layout information.

Beetix commented 4 years ago

@ektek Could you share the code of your extension please? I am looking for a way to share layouts between browsers. Thanks