aptos-move-analyzer
aptos-move-analyzer Introduction
The aptos-move-analyzer is a Visual Studio Code plugin based on move-analyzer improved for Move & Aptos Move by MoveBit. Just now, we used this plugin in our dev member's daily work, and it's an alpha release.
Note:
If you have move-analyzer or sui-move-analyzer installed locally, it is important to disable other plugins according to your current project needs to avoid conflicts and waste of computing resources when using aptos-move-analyzer.
How to Install (Must Read)
The aptos-move-analyzer Visual Studio Code extension works via two components: the extension itself and
the aptos-move-analyzer language server.
1. Installing the aptos-move-analyzer language server
The aptos-move-analyzer language server is a Rust program that is part of the
Move repository. It may be installed in one of two ways:
Use Cargo (Recommended)
Use Rust's package manager cargo to install aptos-move-analyzer in your user's PATH. This
is recommended for people who do not work on core Move.
- If you don't already have a Rust toolchain installed, you should install
Rustup, which will install the latest stable Rust toolchain.
- Invoke
cargo install --git https://github.com/movebit/move --branch feature/aptos_move_analyzer aptos-move-analyzer to install the
aptos-move-analyzer language server in your Cargo binary directory. On macOS and Linux, this is
usually ~/.cargo/bin . You'll want to make sure this location is in your PATH environment
variable.
Manual Install
Clone Move repository yourself and build
aptos-move-analyzer from its source code, which is especially useful if you will work on core Move.
To do so, follow the instructions in the Move tutorial's
Step 0: Installation.
To confirm that you've installed the language server program successfully, execute
aptos-move-analyzer --version on the command line. You should see the output aptos-move-analyzer version number .
2. Installing the aptos-move-analyzer Visual Studio Code extension
- Open a new window in any Visual Studio Code application version 1.55.2 or greater.
- Open the command palette (
⇧⌘P on macOS, or use the menu item View > Command Palette...) and
type Extensions: Install Extensions. This will open a panel named Extensions in the
sidebar of your Visual Studio Code window.
- In the search bar labeled Search Extensions in Marketplace, type aptos-move-analyzer. The
aptos-move-analyzer extension should appear in the list below the search bar. Click Install.
- Open any file that ends in
.move . Or to create a new file, click Select a language, and
choose the Move language. As you type, you should see that keywords and types appear in
different colors.
Troubleshooting
If you see an error message language server executable 'aptos-move-analyzer' could not be found in the
bottom-right of your Visual Studio Code screen when opening a Move file, it means that the
aptos-move-analyzer executable could not be found in your PATH . You may try the following:
- Confirm that invoking
aptos-move-analyzer --version in a command line terminal prints out
aptos-move-analyzer version number . If it doesn't, then retry the instructions in step 1. If it
does successfully print this output, try closing and re-opening the Visual Studio Code
application, as it may not have picked up the update to your PATH .
- If you installed the
aptos-move-analyzer executable to a different location that is outside of your
PATH , then you may have the extension look at this location by using the the Visual Studio Code
settings (⌘, on macOS, or use the menu item Code > Preferences > Settings). Search for the
aptos-move-analyzer.server.path setting, and set it to the location of the aptos-move-analyzer language
server you installed.
- If the above steps don't work, then report
a GitHub issue to the Move repository to get help.
Features
Here are some of the features of the aptos-move-analyzer Visual Studio Code extension. To see them, open a
Move source file (a file with a .move file extension) and:
- See Move keywords and types highlighted in appropriate colors.
- Comment and un-comment lines of code using the
⌘/ shortcut on macOS (or the menu command Edit >
Toggle Line Comment).
- Place your cursor on a delimiter, such as
< , ( , or { , and its corresponding delimiter --
> , ) , or } -- will be highlighted.
- As you type, Move keywords will appear as completion suggestions.
- If the opened Move source file is located within a buildable project (a
Move.toml file can be
found in one of its parent directories), the following advanced features will also be available:
- compiler diagnostics
- go to definition
- go to type definition
- go to references
- type on hover
- outline view showing symbol tree for Move source files
- autocomplete
The changelogs:
2023/07/25 0.0.2
- Added inlay hint to variable.
- Added inlay hint to parameter.
- Added inlay hint to statement.
- Auto reload move.toml when modified.
2023/07/21 0.0.1
- Added semantic analysis to the Move language and Aptos Move, and enhanced some features of the plug-in, such as go-to-definition, auto-completion, finding references, etc.;
- Integrated common Aptos development commands into Command Palette, support Aptos Code Snippets automatic completion (currently only init function);
- Support parallel development of multiple projects under the same directory;
| |