Clarity
Clarity language support
How to install
With Forge Super installed, the button above opens the app on this extension, where you press Install. Nothing is installed until you do.
You can also open the Extensions panel in the app and search for Clarity. The extension's id is clarity.
Don't have Forge Super yet? Download it here.
README
From the extension's repository, written by its authors and not by Mentenaz. See the source.
Clarity Language Support for Zed
This repository adds Clarity language support to the Zed editor. Clarity is a decidable, Lisp-like language used for writing smart contracts on the Stacks Blockchain
This plugin adds the following:
- Clarity LSP support (Requires
clarinetbinary in$PATH) - Tree sitter syntax highlighting using https://github.com/xlittlerag/tree-sitter-clarity
Configuration
The LSP behavior can be customized by adding the following JSON to Zed's settings.json file. This example uses the default values:
"lsp": {
"clarity-lsp": {
"enable_lsp_tasks": true,
"initialization_options": {
"completion": true,
"completionSmartParenthesisWrap": true,
"completionIncludeNativePlaceholders": true,
"documentSymbols": false,
"formatting": true,
"goToDefinition": true,
"hover": true,
"signatureHelp": true,
"debugLogging": false
}
}
},
Architecture
This is a minimal Zed extension with two layers:
Rust WASM extension (src/lib.rs): Implements zed::Extension trait. Does two things:
language_server_command: Locates theclarinetbinary and runs it withlsparglanguage_server_initialization_options: Passes user LSP settings from Zed'ssettings.jsonthrough to the Clarity LSP
Tree-sitter queries (languages/clarity/):
highlights.scm: Syntax highlighting rules mapping tree-sitter nodes to Zed highlight groupsindents.scm: Auto-indentation rules for()and{}formsbrackets.scm: Bracket pair definitions for(),{},<>outline.scm: Outline/symbol view for all top-level definitions and tuple keysconfig.toml: Language metadata: file suffix.clar, line comments;;
Extension manifest (extension.toml): Declares the extension ID (clarity), language server name, and pins the tree-sitter grammar to a specific commit.
Grammar (grammars/): Pre-built clarity.wasm tree-sitter parser. Sourced from the commit pinned in extension.toml. This directory is gitignored — the wasm is built/fetched by Zed at install time.