Skip to content

vittorius/zed-settings-sync

Repository files navigation

Zed Settings Sync

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

ℹ️ This extension doesn't sync project settings files because it's more pragmatic to just check them in the project's VCS repository if needed.

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.

Installation

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

Until then, you can use the dev installation mode.

Configuration

If you already have Zed but you don't have a settings Gist yet

  1. Create a Github token with gist permission scope (detailed guide).
  2. Prepare a Gist (detailed guide).
  3. Add credentials to your Zed settings file:
{
  "lsp": {
    "settings-sync": {
      "initialization_options": {
        "github_token": "gho_my-shiny-token",
        "gist_id": "deadbeefdeadbeefdeadbeefdeadbeef"
      }
    }
  }
}

If you've installed a fresh Zed and want to pull in your settings from an existing Gist

⚠️ Unfortunately, due to the currently limited functionality of Zed extensions in general, the extension itself cannot load settings from a Github Gist. A CLI tool is provided for that purpose.

Ensure you have your Github token and Gist ID at hand.

  1. Install eget
  2. Run eget vittorius/zed-settings-sync --to=~/.local/bin (or any other destination directory you prefer)
  3. Pick the zed-settings-sync-cli binary in the choice provided by eget
  4. Run zed-settings-sync-cli load and follow the instructions

(Of course, you can download and unpack the binary manually from Github releases)

Usage

Syncing to a Github Gist

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

  • edit the settings file ( or zed: open settings file)
  • edit the keymap file ( or zed: open keymap file)
  • edit tasks (zed: open tasks)
  • edit debug tasks (zed: open debug tasks)

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

ℹ️ At some point, Zed has added graphical interface for editing Settings and Keymap. It pops up by default when you run zed: open settings or zed: open keymap workbench action. 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 edit your config files manually, as it was before.

Another approach could be swapping the keymap entries for zed: open settings or zed: open settings file (and for keymap file in a similar fashion):

{
  "bindings": {
    "cmd-,": "zed::OpenSettingsFile",
    "alt-cmd-,": "zed::OpenSettings"
  }
}

Troubleshooting

  • Open LSP logs (dev: open language server logs), find settings-sync LSP server instance running for the specific settings file, and inspect its log
  • File an issue on Github

Development

Dev environment setup

Requirements:

  • Git
  • Rust is required. The easiest way to get rust is by using rustup.
  • Nextest test runner (some tests rely on it to be run without the need of cross-thread synchronization)
  • iprecommit for Git hooks
    • install uv
    • change directory to where you cloned this repository
    • do uv venv
    • do uvx pip install iprecommit
    • do uvx precommit install

Dev extension installation

  1. Clone this repository
  2. CTRL + SHIFT + P and select zed: install dev extension
    1. You may need to install additional build tool dependencies like XCode for macOS, Visual Studio build tools for Windows, etc. See zed: open log for more details when seeing Error: Failed to install dev extension: failed to compile Rust extension popup while trying to install the dev extension.
  3. Choose the directory where you cloned this repository
  4. After installing the extension, reload the workspace (workspace: reload) to start the LSP server

Quick feedback loop when working on the LSP server

Run

cargo xtask-lsp-install

to install the LSP server binary from your local repository to the Zed extension directory. Then, run workspace: reload action within your Zed instance for your dev extension to catch up the updated LSP server binary.

About

Zed settings sync extension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages