This extension provides support for the Cairo programming language. Cairo is the first Turing-complete language for creating provable programs for general computation.
Cairo Language Server is alpha-grade software. Things are moving rapidly. Expect bugs and crashes from time to time.
- code completion with imports insertion
- automatic, incremental analysis
- diagnostic reporting of build warnings and errors
- go to definition
- semantic syntax highlighting
- documentation lookup on hover
- function signature provider
- code formatter
- supports Scarb, the Cairo package manager
- can be configured to use Dojo Engine-specific tooling
Gm! 👋
Whether you are new to Cairo or an experienced Cairo Pharaoh, we hope you will find this extension fitting your needs and making your Cairo development experience more enjoyable.
- Install latest Scarb, preferably via asdf.
- Install the VS Code Cairo extension.
- Open a workspace containing Scarb.toml or just open any Cairo file to automatically activate the extension.
- The extension depends on the Cairo Language Server, which comes bundled with Scarb. The version of Scarb used in the workspace determines the version of Cairo and Cairo Language Server used by the extension.
Happy coding!
This extension can be configured through VS Code's configuration settings.
All settings are under the cairo1.*
section.
Consult the settings UI in VS Code for more documentation.
For questions or inquiries about Cairo, Cairo Language Server and this extension, reach out to us on Telegram or Discord.
Commonly, the Cairo Language Server is distributed with Scarb and can be accessed using the scarb cairo-language-server
command. However, settings are available to use a standalone binary.
First, the extension checks if a path to the Language Server binary has been explicitly specified in the configuration settings under cairo1.languageServerPath
.
If a path is specified, the extension attempts to use the binary at this location, unless the cairo1.preferScarbLanguageServer
setting is set to true
.
It will not fall back to other methods if this path is incorrect!
If cairo1.languageServerPath
is unset (default), the extension then searches for the Scarb binary in the cairo1.scarbPath
setting.
It will not fall back to other methods if this path is incorrect!
If cairo1.scarbPath
is unset, then it searches in your system’s PATH
environment variable.
Note There is no
asdf
for Windows, so this step will not occur there.
Warning You should not rely on this behavior; use configuration or the
PATH
environment variable instead!
Should the search in PATH
fail, the extension employs a more involved logic to locate the asdf
version manager tool on your machine. This step accounts for instances where Scarb is installed via asdf
but asdf
is not available in the system PATH
.
The extension attempts to execute asdf
directly to determine the installed path of Scarb and to use the associated Language Server binary.
If you run into issues with the extension, try these debugging steps:
- Make sure you have the latest version of the extension installed.
- Make sure you have the latest version of Scarb installed.
- Make sure the problem is also not appearing while running
scarb build
. - Try the latest nightly release of Scarb to verify the bug is not fixed yet.
This is simple to do with asdf:
And restart VS Code.
asdf install scarb latest:nightly asdf local scarb latest:nightly
- Check out debug logs for hints on what could go wrong.
In normal operation mode, both this extension and Cairo Language Server are pretty silent in their logs. Logs are emitted to the Output panel in VS Code.
You can enable debug logging to learn more about what's going on. By default, the extension is trying to start the language server with the same logging level as the extension is running itself. To change the logging level, do the following:
- Open the Command Palette (
F1
orCtrl+Shift+P
). - Run the
>Developer: Set Log Level...
command - Find the
Cairo
extension on the list. - Choose the
Debug
level. - Restart VS Code, by running the
>Developer: Reload Window
command.
When sending logs to developers to debug, please include full logs from both the extension and the language server. If you feel brave enough, you can try some of the more advanced debugging techniques described in CairoLS contribution guidelines.
If you have a problem that you think should be fixed, please follow the steps below:
- Submit a new bug report
- Fill out the issue template
- Attach all relevant screenshots, logs with trace (obtained with steps in Troubleshooting)
- Remember to provide as much information as possible. The issue form will guide you through the process.