- Rust 92.9%
- Shell 5.8%
- TypeScript 1.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github | ||
| extension | ||
| lsp | ||
| scripts | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
Environment Checker
A comprehensive environment variable validation solution for Zed, combining a Language Server Protocol (LSP) implementation with a Zed editor extension.
Features
-
Schema Support:
- Zod (TypeScript): Parses Zod schema definitions with
.describe(),.default(), and.register()metadata - Pydantic (Python): Parses Pydantic class definitions with
Field()descriptions and defaults - YAML: Simple custom YAML format for schema definitions
- Zod (TypeScript): Parses Zod schema definitions with
-
Validation:
- Checks for missing required environment variables
- Merges multiple
.envfiles and validates against all schemas - Reports errors with detailed diagnostics
-
Code Actions:
- Append Missing Variables: Adds all missing required environment variables to the current
.envfile - Generate
.env.example: Creates an example file with all schema variables
- Append Missing Variables: Adds all missing required environment variables to the current
-
Hover Support: Shows type, description, default value, and group information when hovering over environment variables
Repository Structure
This is a monorepo containing both the LSP implementation and the Zed extension:
env-checker/
├── extension/ # Zed extension (WASM)
│ ├── src/
│ ├── extension.toml
│ └── languages/
├── lsp/ # LSP binary (Rust)
│ └── src/
├── scripts/ # Build scripts
│ ├── build-extension.sh
│ ├── build-lsp-all.sh
│ └── build-all.sh
└── Cargo.toml # Workspace configuration
Installation
Prerequisites
- Zed editor
- Rust toolchain (for development)
Installing the Extension
From Zed Extensions Marketplace
- Open Zed
- Press
Cmd+Shift+X(macOS) orCtrl+Shift+X(Linux/Windows) - Search for "Environment Checker"
- Click "Install"
From Source
git clone https://github.com/yourusername/env-checker.git
cd env-checker/extension
zed install
The extension will automatically download the appropriate LSP binary on first use.
Usage
Creating a Schema
Create a schema file in your project. The LSP automatically discovers:
Zod (TypeScript)
import { z } from "zod";
type EnvType = "build-time" | "runtime";
export const envRegistry = z.registry<{ envType: EnvType; group: string }>();
export const schema = z.object({
mySecret: z.string()
.default("defaultValue")
.describe("This is a secret value")
.register(envRegistry, { envType: "runtime", group: "Secrets" }),
debug: z.boolean()
.default(false)
.describe("Enable debug mode")
.register(envRegistry, { envType: "build-time", group: "Settings" }),
apiUrl: z.string()
.describe("API endpoint URL")
.register(envRegistry, { envType: "runtime", group: "API" }),
});
Pydantic (Python)
from pydantic import Field
class Configuration:
api_url: str = Field(description="The URL for API service")
debug: bool = Field(description="Enable debug mode", default=False)
optional_var: str = Field(description="Optional variable", default="default_value")
YAML
Create env.schema.yml in your project:
variables:
API_KEY:
type: string
description: "API key for authentication"
required: true
group: "API"
DEBUG:
type: boolean
description: "Enable debug mode"
default: false
group: "Settings"
Using in Zed
- Open a
.envfile in Zed - Missing required variables are highlighted as errors
- Hover over variables to see their schema information
- Use
Cmd+.(macOS) orCtrl+.(Linux/Windows) to see code actions:- "Append missing environment variable(s)": Adds missing vars to the file
- "Create .env.example file": Generates an example file
Configuration
Create .envchecker.json in your project root:
{
"schemaFiles": [
"src/config/schema.ts",
"backend/config.py"
],
"envFiles": [".env", ".env.local"],
"autoDiscover": true,
"groups": {
"runtime": "Runtime Variables",
"build-time": "Build-time Variables"
}
}
Configuration Options
schemaFiles: Array of explicit schema file pathsenvFiles: Glob patterns for.envfiles to monitor (default:.envin root)autoDiscover: Automatically discover schema files (default:true)groups: Custom group name mappings
Development
Building the Extension
./scripts/build-extension.sh
This builds the Zed extension as a WASM module.
Building the LSP
./scripts/build-lsp-all.sh 0.1.0
This builds the LSP binary for all supported platforms:
- Linux (x86_64)
- macOS (ARM64 and x86_64)
- Windows (x86_64)
Building Everything
./scripts/build-all.sh 0.1.0
This builds both the extension and all LSP binaries.
Local Development
- Make changes to the extension or LSP code
- Build the extension:
./scripts/build-extension.sh - In Zed:
zed install(from the extension directory) - Reload Zed:
Cmd+R/Ctrl+R - For LSP changes, rebuild with:
cargo build --release --manifest-path=lsp/Cargo.toml
Testing with Example
- Install extension
- Open
extension/example-projectin Zed - Open
.envfile - Should see diagnostics for missing variables
Release Process
- Update version in
Cargo.tomlworkspace - Build all artifacts:
./scripts/build-all.sh <version> - Create a new GitHub release with tag
v<version> - Upload:
extension/extension.wasm- All
.tar.gzand.zipfiles fromrelease/
- Update extension in Zed Extensions marketplace
Troubleshooting
LSP not starting
- Check Zed's log: Press
Cmd+Shift+P/Ctrl+Shift+P, then "zed: Open Log" - Look for errors related to "env-checker"
- The extension should auto-download the LSP binary on first use
No diagnostics appearing
- Ensure you have a schema file in your project
- Check that
.envfile has.envextension - Reload the window:
Cmd+R/Ctrl+R
License
MIT