Move VSCode Extension
此内容尚不支持你的语言。
Move on Aptos Language Extension
Section titled “Move on Aptos Language Extension”This is the official Visual Studio Code (and Cursor) extension for developing smart contracts in the Move language on the Aptos blockchain.
Built from the ground up, it delivers a modern and performant development experience, offering essential features like semantic highlighting, real-time diagnostics, auto-formatting and seamless integration with the rest of the Aptos toolchain - all designed to help developers build and test Move contracts with ease and confidence.
Actively maintained by the Aptos team, this extension is designed to evolve alongside the Move language and supports both developers who are new to Move, and those building more complex applications.
Features
Section titled “Features”- Semantic Highlighting
- Go to Definition
- Find All References & Symbol Renaming
- Type and Documentation on Hover
- Contextual Auto-Completion
- Inlay Hints for Types and Function Parameters
- Real-Time Diagnostics
- Code suggestions
movefmt
Integration
- Run
#[test]
functions - Check modules and functions with Move Prover
Installation
Section titled “Installation”We publish releases both on VSCode Marketplace and OpenVSX.
We also publish nightly
pre-releases, which are built from main
branch every night. To use those, select Switch to Pre-Release Version from your editor’s Extensions View.
Build from sources
Section titled “Build from sources”Clone the repo, then run:
cargo run -p xtask -- install --server --client
(or just cargo xtask install --server --client
, see https://github.com/matklad/cargo-xtask)
The command builds move-on-aptos.vsix
extension file and installs it into your VSCode.
Then it runs cargo install
to build and install language server.
Put
"move-on-aptos.server.path": "~/.cargo/bin/aptos-language-server",
to your settings.json
to point the extension to your locally built language server.
Build from sources: Cursor AI editor
Section titled “Build from sources: Cursor AI editor”If you use https://www.cursor.com/ AI editor, you need to do a bit more work.
Run the installation command above. The result would be a ./editors/code/move-on-aptos.vsix
vscode extension package.
Then install it from the editor using the "Install from VSIX..."
command.
Configuration
Section titled “Configuration”This extension provides configurations through VSCode’s configuration settings.
All configurations are under move-on-aptos.*
.
Recommended configuration for the Move package directories
Section titled “Recommended configuration for the Move package directories”LSP is somewhat limited in what it can actually do, so some of the settings need to be specified manually.
Mark Move Library sources read-only
Section titled “Mark Move Library sources read-only”Add the following to your settings.json
:
"files.readonlyInclude": { "**/build/*/sources/**/*.move": true, "**/.move/**/*.move": true, }
Auto-close b"
and x"
properly
Section titled “Auto-close b" and x" properly” "[move]": { "editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?bx", },
A bunch of symbols in the config value are the defaults, we’re adding b
and x
symbols for the string prefixes.
Set Organize Imports
command to a keyboard shortcut
Section titled “Set Organize Imports command to a keyboard shortcut” { "key": "ctrl+alt+o", "command": "move-on-aptos.organizeImports", "when": "editorTextFocus && !editorReadonly" }
AdvancedConfiguration
Section titled “AdvancedConfiguration”Diagnostics
Section titled “Diagnostics”Extension provides a number of diagnostics, from hard errors like “unresolved reference” to style lints. Some of those might be less useful than others for different coding styles, so there’s an escape hatch to disable those:
{ "move-on-aptos.diagnostics.disabled": [],}
where values are diagnostic codes from the error messages, like unused-variable
here:
Inlay hints
Section titled “Inlay hints”Type hints for the let statements and lambda parameters are supported.
module 0x1::m { fun main() { let a/*: integer*/ = 1; let f: |u8| u8 = |e/*: u8*/| e; }}
To disable those, use:
{ "move-on-aptos.inlayHints.typeHints.enable": false,}
Formatting (works with movefmt
>= 1.2.1)
Section titled “Formatting (works with movefmt >= 1.2.1)”Specify a path to the movefmt
executable and extra args (like a --config-path
) if necessary:
{ "move-on-aptos.movefmt.path": "~/code/movefmt/target/release/movefmt", "move-on-aptos.movefmt.extraArgs": [],}
Formatting on Save can be enabled in VSCode with
{ "editor.formatOnSave": true,}
Debugging
Section titled “Debugging”It’s useful to enable INFO logging level, it’s not very chatty and could provide with a valuable information to debug:
"move-on-aptos.server.extraEnv": { "RA_LOG": "info" },
Additional commands
Section titled “Additional commands”aptos-language-server diagnostics
Section titled “aptos-language-server diagnostics”Run server diagnostics on the file (or package directory). If --apply-fixes
is provided, automatically applies available autofixes:
See available diagnostics with auto-fixes
$ aptos-language-server diagnostics --apply-fixes replace-with-method-call ./aptos-stdlib/sources/cryptography/keyless.moveprocessing package 'aptos-stdlib', file: /home/mkurnikov/code/aptos-core/aptos-move/framework/aptos-stdlib/sources/cryptography/keyless.movenote[replace-with-method-call]: Can be replaced with method call ┌─ /home/mkurnikov/code/aptos-core/aptos-move/framework/aptos-stdlib/sources/cryptography/keyless.move:67:17 │67 │ assert!(string::bytes(&iss).length() <= MAX_ISSUER_UTF8_BYTES_LENGTH, error::invalid_argument(E_INVALID_ISSUER_UTF8_BYTES_LENGTH)); │ ^^^^^^^^^^^^^^^^^^^ │ ┌─ /home/mkurnikov/code/aptos-core/aptos-move/framework/aptos-stdlib/sources/cryptography/keyless.move:67:17 │67 │ assert!(iss.bytes().length() <= MAX_ISSUER_UTF8_BYTES_LENGTH, error::invalid_argument(E_INVALID_ISSUER_UTF8_BYTES_LENGTH)); │ ^^^^^^^^^^^ after fix
Code suggestions (with fixes)
Section titled “Code suggestions (with fixes)”Use method call notation
Section titled “Use method call notation”Code: replace-with-method-call
Use compound assignment expression
Section titled “Use compound assignment expression”Code: replace-with-compound-expr
Use vector index expr
Section titled “Use vector index expr”Code: replace-with-index-expr
Detects expressions of form *vector::borrow(&some_vector, index)
and *some_vector.borrow(index)
,
which can be converted to some_vector[index]
.
Use field initialization shorthand
Section titled “Use field initialization shorthand”Code: use-struct-lit-field-shorthand
, use-struct-pat-field-shorthand
, use-schema-lit-field-shorthand
Detects struct literal fields which could be written in shorthand form.
Redundant integer type cast
Section titled “Redundant integer type cast”Code: remove-redundant-cast
Detects expressions like number as u8
, where number
is already of type it’s being casted to.
Add _
prefix to the variable name
Section titled “Add _ prefix to the variable name”Code: rename-with-underscore-prefix
Prefixes unused variable with _
.
Roadmap
Section titled “Roadmap”-
More error highlighting:
- Implement more errors from the Aptos Move compiler (like ability checking)
- Implement lints from the
aptos move lint
with extension-provided quickfixes.
-
Working with imports:
- Detect unused imports and remove them with “Organize Imports” VSCode feature.
- Show completion items not imported in the current module, create
use
statements for those automatically.
-
Integration with the
aptos-cli
commands: compile packages, publishing modules and executing transactions. -
Move.toml
support. -
AI integration (via MCP server).