Sway Extension for Zed
Official Zed extension for the Sway programming language, providing comprehensive language support for Fuel smart contracts.
Features
- Language Server Protocol (LSP) integration with
forc-lsp - Syntax highlighting via Tree-sitter grammar
- Code completion and IntelliSense
- Error diagnostics and warnings
- Go to definition and symbol navigation
- Hover documentation and type information
- Inlay hints for types and parameters
Prerequisites
Before using this extension, you need to install the Fuel toolchain:
Installing the Fuel Toolchain
# Install fuelup (Fuel toolchain installer)
curl https://install.fuel.network | sh
# Install the latest Fuel toolchain
fuelup toolchain install latest
fuelup default latest
# Verify installation
fuelup --version
forc --version
forc-lsp --versionThis will install:
forc- The Fuel Orchestrator (Sway compiler)forc-lsp- The Sway Language Serverforc-fmt- Sway code formatterforc-doc- Sway documentation generatorfuel-core- The Fuel node implementation- Other Fuel development tools
Verify Installation
# Verify forc-lsp is available
forc-lsp --versionInstallation
From Zed Extension Marketplace
- Open Zed
- Press
Cmd/Ctrl + Shift + Pto open the command palette - Type "zed: extensions" and select it
- Search for "Sway"
- Click "Install" on the Sway extension
That's it! The extension is automatically available through Zed's built-in extension registry.
Manual Installation (Development Only)
Clone this repository:
git clone https://github.com/FuelLabs/sway-zed-extension.git cd sway-zed-extensionInstall the extension in development mode:
# In Zed, open the command palette and run: # "zed: install dev extension" # Then select this extension directory
Usage
Once installed, the extension will automatically activate for .sw files. The language server will start automatically when you open a Sway project.
Supported File Types
.sw- Sway source files
Project Structure
This extension includes:
extension.toml- Extension metadata and configurationsrc/lib.rs- WebAssembly extension logiclanguages/sway/config.toml- Language configurationlanguages/sway/highlights.scm- Syntax highlighting rules
Troubleshooting
Language Server Not Starting
If the language server isn't working:
Check forc-lsp installation:
which forc-lsp forc-lsp --versionVerify PATH: Ensure
forc-lspis in your system PATHCheck Zed logs: Open Zed logs to see any error messages:
- Open command palette (
Cmd/Ctrl + Shift + P) - Run "zed: open log file"
- Open command palette (
Restart Zed: Sometimes restarting Zed resolves LSP issues
Extension Not Loading
If the extension isn't loading:
- Check the Zed extensions panel for any error messages
- Verify the extension is enabled
- Try disabling and re-enabling the extension
- Restart Zed
Links
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.