Cadence VS Code Extension
This extension integrates [Cadence], the resource-oriented smart contract programming language of Flow, into Visual Studio Code. It provides features like syntax highlighting, type checking, code completion, etc.
Note that most editing features (type checking, code completion, etc.) are implemented in the Cadence Language Server.
Features
- Syntax highlighting (including in Markdown code fences)
- Run the emulator, submit transactions, scripts from the editor
Installation
To install the extension, ensure you have the VS Code IDE installed.
Then, you can install the Cadence extension from the VS Code Marketplace.
Develop the extension
Prerequisites
- Must have Typescript installed globally:
npm i -g typescript
Get started
- Run the Typescript watcher:
tsc -watch -p ./ - Press
F5in VSCode to launch the extension. - Manually reload the extension host when you make changes to TypeScript code.
Configuration for extension host if missing (launch.json):
_13{_13 "version": "0.2.0",_13 "configurations": [_13 {_13 "type": "extensionHost",_13 "request": "launch",_13 "name": "Launch Extension",_13 "runtimeExecutable": "${execPath}",_13 "args": ["--extensionDevelopmentPath=${workspaceFolder}"],_13 "outFiles": ["${workspaceFolder}/out/**/*.js"]_13 }_13 ]_13}
Build
If you build the extension from source, you need to build both the extension itself and the Flow CLI (if you don't already have a version installed). Unless you're developing the extension or need access to unreleased features, use the Flow CLI install option (above). It's much easier!
If you haven't already, install dependencies.
Next, build and package the extension.
This will result in a .vsix file that contains the packaged extension.
Install the packaged extension.
Restart VS Code and the extension is installed!