Skip to content

vittorius/zed-settings-sync

Repository files navigation

Zed Settings Sync is an extension for Zed that aims to add support of automatically syncing your global and per-project config files to a Github Gist using LSP.

Using LSP is a workaround because of the limited capabilities of current Zed extensions API.

Such an approach is heavily inspired by Zed Discord Presence extension.

Requirements

rust is required for installing this extension.
The easiest way to get rust is by using rustup.

How to install?

Dev installation

  1. Clone this repository
  2. CTRL + SHIFT + P and select zed: install dev extension
  3. Choose the directory where you cloned this repository
  4. Enjoy :)

Normal installation

When a corresponding Zed extensions repo PR is created and merged, you can simply download the extension in zed: extensions.

How to configure?

Prepare a Github token

Using Github CLI

This is the easiest way.

  1. Install the official Github CLI
  2. Login to Github using it
  3. Ensure your token has the gist OAuth scope (it should, by default):
gh auth status
  1. Copy your token to the clipboard and paste it into your configuration file:

macOS:

gh auth token | pbcopy

Linux:

gh auth token | xclip -selection clipboard

Windows:

gh auth token | clip
  1. Paste it into your Settings Sync configuration:
{
  // ...
  "lsp": {
    // ...
    "settings_sync": {
      "initialization_options": {
        "github_token": "<your Github token>"
        // ...
      }
    }
  }
}

Create a token yourself

  1. Create a new token at Github.
  2. Ensure it has Gists permission under the Account.
  3. Perform all of the steps from the previous section to land this token into your Settings Sync LSP server configuration.

Prepare a Gist

You need to create a Gist or have an existing one. If you're creating a new one, remember that it cannot be empty or contain zero-sized files. So, to create a Gist for our purposes, again, we have 2 options.

Github CLI

macOS / Linux:

echo "// Zed Settings\n\n{\n}\n" | gh gist create -f settings.json -d "Zed Settings"

Windows:

echo //^ Zed^ Settings| gh gist create -f settings.json -d "Zed Settings"

curl

macOS / Linux:

curl -X POST -H "Authorization: token <your Github token>" -H "Content-Type: application/json" -d '{"description": "Zed Settings", "public": false, "files": {"settings.json": {"content": "// Zed Settings\n\n{\n}\n"}}}' https://api.github.com/gists

Windows:

curl.exe -X POST -H "Authorization: token <your Github token>" -H "Content-Type: application/json" -d "{\"description\":\"Zed Settings\",\"public\":false,\"files\":{\"settings.json\":{\"content\":\"// Zed Settings\n\n{\n}\n\"}}}" https://api.github.com/gists

Insert Gist ID into your Settings Sync configuration

  1. Paste it into your Settings Sync configuration:
{
  // ...
  "lsp": {
    // ...
    "settings_sync": {
      "initialization_options": {
        "gist_id": "<your Gist Id>"
        // ...
      }
    }
  }
}

Example configuration

{
  "lsp": {
    "settings_sync": {
      "initialization_options": {
        "github_token": "gho_nA8tK4GxW9eR1bY0uZqT7sL2pCjD5vFhE",
        "gist_id": "e565898c6f664eb916c54de1e99ebe74"
      }
    }
  }
}

How to use?

Given, you've configured everything correctly, now you can:

  • edit global Zed settings (zed: open settings or zed: open settings file)
  • edit project settings (zed: open project settings)
  • edit the keymap (zed: open keymap or zed: open keymap file)
  • edit tasks (zed: open tasks)
  • edit project tasks (zed: open project tasks)
  • edit debug tasks (zed: open debug tasks)
  • edit project debug tasks (debugger: open project debug tasks)

After the file is saved, either manually, or triggered by the auto-save feature, it will be synchronized to the Gist you've specified.

⚠️ Unfortunately, it does work the other way. In theory, we could make the LSP server download settings files from the cloud and put it in right place on your local machine. But that would be too hacky and fragile.

ℹ️ Recently, Zed has added graphical interface for editing Settings and Keymap. When using such an editor, click Edit in settings.json or Edit in keymap.json respectively. You can go back to the visual editor and use it afterward, just keep the corresponding JSON settings file open for it to be caught by LSP and synchronized appropriately. Or, of course, you can play hard and edit your config files manually, as it was before.

Troubleshooting

  • Open LSP logs (dev: open language server logs), find Settings Sync LSP server, and inspect its log
  • File an issue on Github

Development

  • TODO: install rust and other components via rustup
  • TODO: install iprecommit (install uv, do uv venv, do ux pip install iprecommit)
  • TODO: other neccessary setup

About

Zed settings sync extension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages