Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for LSP with different IDEs #4801

Merged
merged 4 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
- [Testing with Rust](./testing/testing-with-rust.md)
- [Application Frontend](./frontend/index.md)
- [TypeScript SDK](./frontend/typescript_sdk.md)
- [Sway LSP](./lsp/index.md)
- [Installation](./lsp/installation.md)
- [Features](./lsp/features.md)
- [Sway Reference](./reference/index.md)
- [Compiler Intrinsics](./reference/compiler_intrinsics.md)
- [Attributes](./reference/attributes.md)
Expand Down
6 changes: 1 addition & 5 deletions docs/book/src/introduction/fuel_toolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ The "Fuel Orchestrator" [Forc](https://github.com/FuelLabs/sway/tree/master/forc

## Sway Language Server (`forc-lsp`)

The Sway Language Server `forc-lsp` is provided to expose features to IDEs. [Installation instructions](./installation.md).

Currently, only [Visual Studio Code is supported through a plugin](https://marketplace.visualstudio.com/items?itemName=FuelLabs.sway-vscode-plugin). Vim support is forthcoming, though [syntax highlighting is provided](https://github.com/FuelLabs/sway.vim).

> **Note**: There is no need to manually run `forc-lsp` (the plugin will automatically start it), however both `forc` and `forc-lsp` must be in your `$PATH`. To check if `forc` is in your `$PATH`, type `forc --help` in your terminal.
The Sway Language Server `forc-lsp` is provided to expose features to IDEs. [Installation instructions](../lsp/installation.md).

## Sway Formatter (`forc-fmt`)

Expand Down
49 changes: 49 additions & 0 deletions docs/book/src/lsp/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Features

## Code Actions

_Source:_ [code_actions](https://github.com/FuelLabs/sway/tree/master/sway-lsp/src/capabilities/code_actions)

Quickly generate boilerplate code and code comments for functions, structs, and ABIs.

## Completion

_Source:_ [completion.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/completion.rs)

Suggests code to follow partially written statements for functions and variables.

## Diagnostics

_Source:_ [diagnostic.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/diagnostic.rs)

Displays compiler warnings and errors inline.

## Syntax Highlighting

_Source:_ [highlight.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/highlight.rs)

Highlights code based on type and context.

## Hover

_Source:_ [hover](https://github.com/FuelLabs/sway/tree/master/sway-lsp/src/capabilities/hover)

Provides documentation, compiler diagnostics, and reference links when hovering over functions and variables.

## Inlay Hints

_Source:_ [inlay_hints.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/inlay_hints.rs)

Displays the implied type of a variable next to the variable name. Configurable in Settings.

## Rename

_Source:_ [rename.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/rename.rs)

Renames a symbol everywhere in the workspace.

## Run

_Source:_ [runnable.rs](https://github.com/FuelLabs/sway/blob/master/sway-lsp/src/capabilities/runnable.rs)

Shows a button above a runnable function or test.
14 changes: 14 additions & 0 deletions docs/book/src/lsp/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Sway LSP

Welcome to the documentation for Sway LSP, the language server designed specifically for the Sway programming language. This documentation serves as a comprehensive guide to help you understand and utilize the powerful features provided by Sway LSP.

Sway LSP is built on the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP), a standardized protocol for enabling rich programming language support in editor and IDE environments. It acts as a bridge between your favorite code editor or integrated development environment and the Sway programming language, offering advanced semantic analysis and a wide range of features to enhance your development experience.

With Sway LSP, you can expect a seamless and efficient coding experience while working with the Sway programming language. It provides intelligent code completion, precise symbol navigation, type information, and other smart features that empower you to write clean and error-free code. By leveraging the power of Sway LSP, you can increase productivity, reduce debugging time, and write high-quality code with confidence.

In this documentation, you will find detailed information about how to set up Sway LSP in your preferred code editor or IDE, configure its settings to match your coding style, and take advantage of its various features. We will guide you through the installation process, provide examples of typical configuration setups, and walk you through the usage of each feature supported by Sway LSP.

Whether you are a beginner or an experienced Sway developer, this documentation aims to be your go-to resource for understanding and maximizing the capabilities of Sway LSP. So let's dive in and unlock the full potential of the Sway programming language with Sway LSP!

- [Installation](./installation.md)
- [Features](./lsp/features.md)
27 changes: 27 additions & 0 deletions docs/book/src/lsp/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Installation

The Sway language server is contained in the [forc-lsp](../forc/plugins/forc_lsp.md) binary, which is installed as part of the [Fuel toolchain](../introduction/fuel_toolchain.md). Once installed, it can be used with a variety of IDEs. It must be installed for any of the IDE plugins to work.

> **Note**: There is no need to manually run `forc-lsp` (the plugin will automatically start it), however both `forc` and `forc-lsp` must be in your `$PATH`. To check if `forc` is in your `$PATH`, type `forc --help` in your terminal.

## VS Code

This is the best supported editor at the moment.

You can install the latest release of the plugin from the [marketplace](https://marketplace.visualstudio.com/items?itemName=FuelLabs.sway-vscode-plugin).

Note that we only support the most recent version of VS Code.

## vim / neovim

Follow the documentation for [sway.vim](https://github.com/FuelLabs/sway.vim) to install.

## helix

[Install helix](https://docs.helix-editor.com/install.html) and Sway LSP will work out of the box.

Sway support is built into helix using [tree-sitter-sway](https://github.com/FuelLabs/tree-sitter-sway).

## Emacs

Coming soon! Feel free to [contribute](https://github.com/FuelLabs/sway/issues/3527).