sway-lsp 0.66.5

LSP server for Sway.
Documentation

Sway Language Server

Visual Studio Marketplace Version discord

This extension provides LSP support for the Sway smart contract programming language.

Features

  • go-to type definition
  • types and documentation on hover
  • inlay hints for types and parameter names
  • semantic syntax highlighting
  • symbol renaming
  • code actions
  • imports insertion

Coming Soon

  • code completion
  • apply suggestions from errors
  • find all references, workspace symbol search
  • ... and many more

Quick start

  1. Install the Fuel toolchain.
  2. Ensure forc-lsp is installed correctly by entering forc-lsp --version into your terminal.
  3. Install the Sway VSCode plugin.

Trying out the local version

To try out the local LSP version:

  1. Install the local version of the server: cargo install --path ./forc-plugins/forc-lsp.
  2. Open VSCode settings and set the Sway-lsp › Diagnostic: Bin Path to the installed forc-lsp binary. The path to the binary will be listed at the end of the cargo install command and is usually: /home/<user>/.cargo/bin/forc-lsp.
  3. Open an arbitrary Sway project. E.g., ./examples/arrays.
  4. Open the Output window in VSCode and select Sway Language Server from the drop down menu.
  5. Start coding and observe the LSP output in the Output window. This window will also show any dbg! or eprintln! lines.