Question
· Jun 16, 2020

Multiple server connections in VS Code?

Hi!

As Atelier for Eclipse seems that will be discontinued, I decided to start moving my coding environment to Visual Studio Code. I kind of like it, and I'm getting used to it.

But I can't find the way to have several server connections as I do in Eclipse, and so creating projects based on that servers. Is there any way to do it?

 

Thanks a lot

Discussion (14)0
Log in or sign up to continue

I have taken a similar approach. I have a root directory 'Visual Studio Code' and under that I have a number of sub directories. Each of which contains a VS Code workspace file which looks like this:

{
    "folders": [
        {
            "path": "."
        },
        {
            "name": "XXX-XXXX-Interface-GIT",
            "path": "..\\..\\XXX-XXXX-Interface-GIT"
        }
    ],
    "settings": {
        "objectscript.conn.ns": "XXXX-QC",
        "objectscript.conn.password": "**********",
        "objectscript.conn.username": "*******",
        "objectscript.conn.active": true,
        "objectscript.conn.host": "NN.NN.NN.NN",
        "objectscript.conn.docker-compose.internalPort": 57772,
        "objectscript.conn.port": 57772,
        "objectscript.serverSideEditing": true,
        "objectscript.suppressCompileErrorMessages": true
    }
}

I have used 'X''s to obscure my actual Git, Namespace and Server settings and '*''s for my username and password.

Any settings that are universal I put into the VS Code .settings file which is stored in the windows->users->local-> ... directory

Settings such as Objectscript code snippets live in a .vscode file in my windows user settings directory.

This doesn't allow for multiple workspaces to be open at the same time but you can have multiple instanv=ces of VS code open, each one pointing to a different server/namespace where you are working.

VSCode-ObjectScript extension which I suppose you already use, support the way, to work at the same time with multiple connections. And Mathew, gives you an example how to configure it. Look at the project. Important file there is multi.code-workspace, it's a kind of project file for VSCode, where is defined two folders, and each of those folders has its own separate settings for InterSystems. So, it means each folder will have its own connection to its own server. And you can configure as many connections as you would like. With the next release, I think it will be available one more way how to achieve the same.

Look at the project mentioned earlier.
This part

{
  "folders": [
    {
      "name": "main",
      "path": "."
    },
    {
      "name": "part1",
      "path": "part1"
    },{
      "name": "part2",
      "path": "part2"
    }
  ]
}

Mentions three folders, where part1 and part2 supposed to be used to connect to two different servers. And each folder, have own .vscode/settings.json, which contains own settings to the server.

Hi Dmitriy,

I've created the .code-workspace file up as you've described, with the "main" name/path and the "part" names/paths pointing to their respective subdirectories. Each subdirectory has it's own .vscode/settings.json file. However, when I go into Explorer, all of the workspace directories show connections to the same server, not the distinct ones defined for each workspace subdirectory.

There are no objectscript.* values defined in the main .code-workspace file or the .vscode/settings.json file in the root of the main workspace directory.

I'm obviously missing something, but I've tried a variety of options and I'm stuck.

Thanks!

First of all, you have to open this .code-workspace file with VSCode, it should offer to do it if you did not. Next, path is relevant to .code-workspace file location, and should contain own .vscode/settings.json. If all conditions are met, but behaviour not expected, please fill the issue, with examples, and screenshots, I'll try to reproduce and find the solution.

Hi Dmitriy,

UPDATE: Also posted as an issue to GitHub

Here's the layout in VS Code's Explorer:

The code-workspace file from the Workspace top-level directory:

Note that I've tried both manually creating the file and adding directories to the workspace using the VS Code menus. The only difference I can see in the result is that the json name value appears in the explorer tree rather than the actual directory name.

Hers's a .vscode\settings.json file from one of the directories referenced in the code-workspace file shown above:

The oddest symptom is that when I change just one of the settings.json files, all directories change to those value in the OBJECTSCRIPT:EXPLORER view (only the file I've actually edited and saved has the changes in it, though):

Thanks for looking into this.

PS.

Just in case it matters:

Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18362

0.8.8 now when you save your code locally changed on the server, should warn you about it, and should offer to review, just load from the server or overwrite changes on server.

There is no full synchronization, yet at the moment. Could you fill the issue, if you would need exactly this feature? And explain how would you like to see it?  

If you don't care about your local changes, and want to get the latest server's version of code, just export needed from Explorer view, or export everything by the command `Export sources` from command palette. You have to have correct `objectscript.export` settings, so, your exported sources will overwrite your local files correctly.