DEV Community

loading...

Code Settings Sync Configurations

Shan Khan
Originally published at shanalikhan.github.io on ・4 min read

There are two types of configurations for Settings Sync in terms of their scope.

  • Gist Setting
  • Global Settings

Setting Sync Global Settings is the setting which applies on all the Visual Studio Code environment while the scope of Gist Settings are only limited to Visual Studio current environment.

For Example: GitHub Token is a part of Global Settings of two reasons, first its sensitive information for the user that we cannot allow to upload the GitHub token along-with code settings in Gist. Second its applicable with all Gist, it's required to download any Gist.

Gist Settings

{  
    "sync.gist": "",
    "sync.autoDownload": false,
    "sync.autoUpload": false,
    "sync.forceDownload": false,
    "sync.removeExtensions": true,
    "sync.syncExtensions": true,
    "sync.forceUpload": false,
    "sync.quietSync": false
}

Gist Settings are stored in Visual Studio code settings.json with the sync prefix and may vary with different Gist ( Visual Studio Environments) and will be replaced by the new downloaded Settings.

  • Gist: Github Gist ID
  • autoDownload: false by default. If you set it to true it will download the settings automatically when code is started.
  • autoUpload : false by default. It will start download process automatically when Visual Studio Loads when set to true , false will not allow extension to auto download the settings upon startup.
  • quietSync : false by default. It will show the summary page when download or upload process completes displaying the files changed and extensions added or removed. Setting false will allow quiet process in the background and only notify via editor statusbar.
  • forceDownload : false by default. If you set it to true it will overwrite the existing settings everytime the download process initiated either manually or on start.
  • syncExtensions : true by default. It allows Settings Sync to sync your extensions list in gist so when you download it will automatically install the extensions list in code.
  • removeExtensions: true by default. When syncExtensions is true and extensions list are downloaded. It allows Setting Sync to remove those extensions which are not a part of downloaded list of extensions. If you want to sync with new extensions and dont want to remove extra extensions keep this config to false Settings sync will not delete extensions.
Global Settings

Global Settings are stored in the User folder with the file name syncLocalSettings.json.

{
    "ignoreUploadFiles": [
        "state.*",
        "syncLocalSettings.json",
        ".DS_Store",
        "sync.lock",
        "projects.json",
        "projects_cache_vscode.json",
        "projects_cache_git.json",
        "projects_cache_svn.json",
        "gpm_projects.json",
        "gpm-recentItems.json"
    ],
    "ignoreUploadFolders": [ "workspaceStorage"],
    "ignoreExtensions": [],
    "gistDescription": "Visual Studio Code Settings Sync Gist",
    "version": 341,
    "token": "",
    "downloadPublicGist": false,
    "supportedFileExtensions": [ "json","code-snippets"],
    "disableUpdateMessage": false,
    "lastUpload": null,
    "lastDownload": null,
    "githubEnterpriseUrl": null,
    "askGistName": false,
    "customFiles": {},
    "hostName": null,
    "universalKeybindings": false,
    "autoUploadDelay": 20
}
  • ignoreUploadFiles: All the files inside this key will stop extension to upload the files. You need to only write the file name of file. Any file found with this name inside User folder or subfolders won’t be uploaded. Like in the above example, the projects.json and projects_cache_git.json will not be uploaded to Github Gist.

  • ignoreUploadFolders: All the folder names defined in it will not be uploaded in Gist, Folder can be child of User folder or child of any subfolder. Like in the above example, workspaceStorage folder files will not be uploaded to Github Gist.

  • gistDescription: This is the name of gist you are going to create. Very helpful when you have multiple environments ( e.g Home Settings, Work Settings ) you can name those gist and download them by identifying.

  • token: The GitHub User secret identifier in order to allow Settings Sync upload and download the gist. Token is automatically generated by the Settings Sync UI when you login via GitHub. You can also manual generate token from Github and paste here.

  • supportedFileExtensions: It allows Settings Sync to upload only the files in gist which extension are defined. By default Settings Sync only uploads json and code-snippets.

  • downloadPublicGist: false by default. Set it to true if you are looking forward to make Setting Sync only download mode. For example, team member looking forward to the team environment. Set it to true and Settings Sync will only download the Gist and will never ask for token in order to download.

  • ignoreExtensions: Add any extension name in order to ignore from upload / download process. For example : Add beautify if you want to ignore beautify extension to upload and download from the Gist.

  • disableUpdateMessage: false by default. Set it to true when you are looking forward to disable the extension update messages.

  • githubEnterpriseUrl and hostName: Setup enterprise url and hostname when you want to use Github enterprise for Settings Sync.

  • askGistName: - askGistName: false by default. When set to true allows user to set Gist name while creating new one. Very helpful when you have multiple environments ( e.g Home Settings, Work Settings ) you can name those gist and download them by identifying.

  • universalKeybindings: false by default. Set it to true if you want a single keybindings.json for MacOS, Linux and Windows.

  • autoUploadDelay: Default is 20 seconds. Change the seconds interval to allow Settings Sync to upload the settings on change.

  • customFiles: Allow you to sync files outside the User folder. For details read the wiki post here

lastDownload and lastUpload is just to keep record of download and upload status. You can set it to empty to hit manual download process.

Let me know if you have any questions.

Discussion (8)

Collapse
sarafian profile image
Alex Sarafian

I want to bootstrap an environment. So I've figured where and how to create the necessary configuration files with the gist and token and I want afterwards to invoke the download of the settings which you would normally do from the command pallete.

Something like this

code aparameter extensionname command
Enter fullscreen mode Exit fullscreen mode

e.g.

code shan.code-settings-sync extension.downloadSettings
Enter fullscreen mode Exit fullscreen mode
Collapse
mosthated profile image
MostHated • Edited

I have been looking for quite some time for a solid way to do exactly this. I do have it pretty close, though. It doesn't run headless, but it is fully automated. I just finished it up about an hour ago, and was going to make a small writeup on here about it.

Collapse
sarafian profile image
Alex Sarafian

VSCode support this natively so I would say that the entire post and comments as an extention are obsolete

Thread Thread
mosthated profile image
MostHated

Do you happen to have an example or a link to info on it? I have looked everywhere and have not seen a way to externally/headlessly call an extensions methods from outside of the VSCode editor.

Thread Thread
sarafian profile image
Alex Sarafian

Oh that. Yes I would like that as well very much.

I got probably confused and thought you were also interested for the extension and I said that vscode does this natively.

Thread Thread
mosthated profile image
MostHated

Ah yes, I see what you meant. Though, I can't say I fully agree. While it is nice that the editor does have some sync functionality built-in, it is not as configurable and customizable as this.

I tried using the built-in version but quickly found myself coming back to this one due to the nice platform-specific sync options, inclusions, exclusions, and things of that nature, as my desktop is Linux but I have Windows VM's and my work machines are Windows, etc. I just ended up frustrated more than anything else with the built in sync.

Thread Thread
sarafian profile image
Alex Sarafian

Oh. Didn't get that advanced.

Collapse
davidhartman00 profile image
David Hartman

One extensions needs an absolute file path in its settings.json configuration. The issue is that the path /Users/[Username_For_First_Mac]/files/workspace does not match up with the path /Users/[Username_For_Second_Mac]/files/workspace.

Is there a way to have Settings Sync ignore just this one setting to this extension?