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 VSCode extension documentation #20385

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions docs/content/guides/developer/getting-started/sui-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ Sui requires the following additional tools on computers running Windows.

With Sui installed, you can interact with Sui networks using the Sui CLI. For more details, see the [Sui CLI](/references/cli.mdx) reference.

## Installing Sui developer tools

If you use VSCode, you can install the [Move extension](https://marketplace.visualstudio.com/items?itemName=mysten.move) to get language server support for Move, as well as support for building, testing, and debugging Move code within the IDE.
You can install the extension either by searhing the fully-qualified extension name, `Mysten.move`, in the extension view, or by pressing `Ctrl-P` or `Cmd-P` and typing `ext install mysten.move`.
Installing the Move extension also installs the appropriate `move-analyzer` binary for your operating system, as well as the [Move Trace Debugger](https://marketplace.visualstudio.com/items?itemName=mysten.move-trace-debug) extension, and [Move Syntax](https://marketplace.visualstudio.com/items?itemName=damirka.move-syntax) extension.

There are also community Move packages for [Emacs](https://github.com/amnn/move-mode) and [Vim](https://github.com/yanganto/move.vim).

## Next steps {#next-steps}

Now that you have Sui installed, it's time to start developing. Check out the following topics to start working with Sui:
Expand Down
11 changes: 11 additions & 0 deletions docs/content/references.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ Access Sui Move functions on chain using the Sui Move CLI.
</Card>
</Cards>

## Sui IDE Support

Use the [Move](https://marketplace.visualstudio.com/items?itemName=mysten.move) and [Move Trace Debugger](https://marketplace.visualstudio.com/items?itemName=mysten.move-trace-debug) extensions for VSCode to quickly navigate and edit your Move codebase, and debug execution traces.

<Cards>
<Card title="Move" href="references/ide/move"/>
<Card title="Move Trace Debugger" href="references/ide/debugger"/>
</Cards>



## Sui software development kits

Official software development kits (SDKs) available for Sui include the TypeScript SDK and Rust SDK.
Expand Down
4 changes: 4 additions & 0 deletions docs/content/references/cli/cheatsheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ The cheat sheet highlights common Sui CLI commands.
<td class="w-2/3">`sui move test`</td>
<td class="w-1/3">Test the Move project in the current directory</td>
</tr>
<tr>
<td class="w-2/3">`sui move test --trace-execution`</td>
<td class="w-1/3">Create an execution trace for the Move tests in the current directory. Use with the [Move Trace Debugger](https://marketplace.visualstudio.com/items?itemName=mysten.move-trace-debug) extension.</td>
</tr>
</tbody>
</table>

Expand Down
55 changes: 55 additions & 0 deletions docs/content/references/ide/debugger.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Move Trace Debugger
description: Debug Move execution traces directly in VS Code to understand how your code executes.
---
tedks marked this conversation as resolved.
Show resolved Hide resolved

The [Move Trace Debugger](https://marketplace.visualstudio.com/items?itemName=mysten.move-trace-debug) extension for Visual Studio Code provides a familiar debugging interface for Move unit tests. You can step through code execution, track local variable values, and set line breakpoints to understand how your Move code executes.

:::info
If you have the Move extension installed, you already have the Move Trace Debugger and don't need to install it separately.
:::

tedks marked this conversation as resolved.
Show resolved Hide resolved
The Move Trace Debugger extension is available in the Visual Studio Code Marketplace. Search for `Move Trace Debugger` in the **Extensions** view, or press <kbd>Ctrl</kbd> + <kbd>P</kbd> or <kbd>⌘</kbd> + <kbd>P</kbd> and type `ext install mysten.move-trace-debug`.
You can also run `code --install-extension mysten.move-trace-debug` to install the extension from the command line.

To use the debugger, you must also have the `sui` binary installed with the `tracing` feature flag enabled. The `sui` binary in release tarballs, Homebrew, and Chocolatey, have this feature enabled.
See [Install Sui](../../guides/developer/getting-started/sui-install.mdx) for more information, including how to build from source.

## Usage

Debugging a Move unit test is a two-step process:

1. Generate execution traces:
- Open the command palette (<kbd>⇧</kbd> + <kbd>⌘</kbd> + <kbd>P</kbd> on macOS, <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> on Windows/Linux)
- Run the `Move: Trace Move test execution` command
- Find the generated trace in the `traces` directory.

![Move Trace generation in the command palette](./images/trace_palette.png)

2. Start debugging:
- Open the Move file containing your test
- Select **Run** -> **Start Debugging** from the menu
- If the file has multiple tests, select the specific test from the dropdown menu


![Start debugging](./images/start_debugging.png)

![Test selection](./images/test_selection.png)

## Features

tedks marked this conversation as resolved.
Show resolved Hide resolved
Currently, the Move Trace Debugger supports basic forward debugging through test execution traces.
Reverse debugging and watch expressions are not yet supported.

### Stepping through code execution

![Stepping through code execution](./images/debugger_running.png)

Move Trace Debugger supports standard debugging features like step over, step into, step out, continue, and stop. You can step through normal code, and also Move macros.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a disclaimer here (or maybe we have a more general one elsewhere) that e.g., macros are supported, but are a known pain point that we are working on improving still.


### Tracking variable values

Move Trace Debugger supports displaying the values of primitive types, Move structs, and references.
At present, the debugger doesn't support setting watchpoints on variables.

![Variable values](./images/variables.png)
Binary file added docs/content/references/ide/images/commands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/content/references/ide/images/hover_fun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/content/references/ide/images/variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions docs/content/references/ide/move.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Move Analyzer VSCode Extension
description: The Move extension provides language support features like code navigation, completion, and diagnostics for Move source code.
---
tedks marked this conversation as resolved.
Show resolved Hide resolved
The Move Analyzer extension for Visual Studio Code provides language support features for the Move programming language. It enables syntax highlighting, code completion, and advanced features like definition linking and type checking.

## Installing

You can install the Move extension from the Visual Studio Code Marketplace:

- Open VS Code
- Open the Extensions view (<kbd>⇧</kbd> + <kbd>⌘</kbd> + <kbd>X</kbd> on macOS, <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>X</kbd> on Windows/Linux)
- Search for `mysten.move`
- Click **Install** on the Move extension by Mysten Labs

You can also use <kbd>Ctrl</kbd> + <kbd>P</kbd> or <kbd>⌘</kbd> + <kbd>P</kbd> and type `ext install mysten.move` to install the extension, or install via the command line:

```bash
code --install-extension mysten.move
```

Installing the Move extension also installs the following extensions:

- [Move Syntax](https://marketplace.visualstudio.com/items?itemName=damirka.move-syntax)
- [Move Trace Debugger](https://marketplace.visualstudio.com/items?itemName=mysten.move-trace-debug)

### Installing `move-analyzer`

The Move extension attempts to install the appropriate `move-analyzer` binary for your platform. If this doesn't work, or you prefer to install it manually, build it with Cargo:

```bash
cargo install --git https://github.com/MystenLabs/sui.git sui-move-lsp
```
By default, the Move extension expects to find the `move-analyzer` binary in `~/.sui/bin`. You can either copy the binary here, or configure the extension to use a different path.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to worry about specifying the location for windows users? I'm guessing not since the only way they can install it is with choco I'm guessing?


## Features

tedks marked this conversation as resolved.
Show resolved Hide resolved
The Move extension supports most Language Server Protocol features as well as basic commands for building, testing, and tracing Move code.

### Build, Test, and Trace

The Move extension installs command palette commands for building, testing, and tracing Move code.

![Move commands in the command palette](./images/commands.png)

These commands find the `Move.toml` file for the open Move source file and open a terminal to run the appropriate `sui move` command.

To generate a trace, you need to have a trace-capable `sui` binary. See [Debugger](./debugger.mdx) for more information.

### Syntax highlighting

The [Move Syntax](https://marketplace.visualstudio.com/items?itemName=damirka.move-syntax) extension provides syntax highlighting.

### Hover information

Hovering over identifiers shows type information, struct fields and attributes, and docstrings (if any) for the identifier. This works for all Move symbols including macros.

![Struct hoverover](./images/hover_struct.png)
![Function hoverover](./images/hover_fun.png)
![Macro hoverover](./images/hover_macros.png)

### Code completion

The Move extension autocompletes upon a dot operator, displaying the available methods and fields for the type.

![Code completion](./images/dot_completion.png)


### Definition linking

The move extension supports `go-to-definition` linking for all Move symbols including types, functions, and macros, as long as the type was present when move-analyzer last built the file.
Loading