Quick Start
Scaffold a new language pack using the Fresh CLI:Package Structure
Package Manifest
Thepackage.json configures all aspects of your language pack:
The
$schema field enables validation and autocomplete in editors that support JSON Schema.Grammar Configuration
Thegrammar section tells Fresh how to syntax-highlight your language:
| Field | Type | Description |
|---|---|---|
file | string | Path to grammar file (relative to package root) |
extensions | string[] | File extensions without dots (e.g., ["py", "pyw"]) |
firstLine | string | Optional regex for shebang detection (e.g., "^#!.*python") |
Language Configuration
Thelanguage section configures editor behavior for your language:
| Field | Type | Description |
|---|---|---|
commentPrefix | string | Line comment prefix (e.g., //, #, --) |
blockCommentStart | string | Block comment opening (e.g., /*, <!--) |
blockCommentEnd | string | Block comment closing (e.g., */, -->) |
tabSize | number | Default indentation width (e.g., 4, 2) |
useTabs | boolean | Use tabs instead of spaces for indentation |
autoIndent | boolean | Enable automatic indentation |
formatter.command | string | Formatter executable (e.g., prettier, rustfmt) |
formatter.args | string[] | Arguments for formatter (file path added automatically) |
Formatter Examples
The file path is automatically appended to args. Some formatters expect stdin (use
"-" as arg), others expect a file path.LSP Integration
Thelsp section configures Language Server Protocol support:
| Field | Type | Description |
|---|---|---|
command | string | LSP server executable name or path |
args | string[] | Command-line arguments (e.g., ["--stdio"]) |
autoStart | boolean | Start server automatically when opening matching files |
initializationOptions | object | Custom LSP initialization options (language-specific) |
Finding LSP Servers
Official LSP Registry
Microsoft’s official list of LSP implementations
langserver.org
Community-maintained directory of language servers
Common LSP Servers
| Language | Server | Command | Installation |
|---|---|---|---|
| Rust | rust-analyzer | rust-analyzer | rustup component add rust-analyzer |
| TypeScript/JavaScript | typescript-language-server | typescript-language-server | npm install -g typescript-language-server |
| Python | pyright | pyright-langserver | npm install -g pyright |
| Go | gopls | gopls | go install golang.org/x/tools/gopls@latest |
| C/C++ | clangd | clangd | System package manager |
| Ruby | solargraph | solargraph | gem install solargraph |
| Java | jdtls | jdtls | Eclipse JDT LS |
Advanced LSP Configuration
Some language servers accept custom initialization options:Grammar Development
Fresh uses Sublime Text’s.sublime-syntax format (YAML-based) for syntax highlighting.
Finding Existing Grammars
Before writing a grammar from scratch, search for existing ones:Check VS Code Extensions
Many VS Code extensions use TextMate or Sublime grammars that you can adapt
Browse Package Control
Visit packagecontrol.io for Sublime Text packages
Grammar Compatibility
Will NOT work:- Grammars using
extends: Packages/...directive (grammar inheritance) - References to external grammars or packages
- Dependencies on other grammar files
- Standalone, self-contained grammars
- Grammars using only
includefor internal contexts - No external dependencies
- See fresh-plugins/languages for working examples (templ, hare, solidity)
- Standalone grammars from Package Control that don’t use
extends
Testing Compatibility
Install your language pack locally (see Testing) and check logs:Failed to parse grammar errors.
Attribution Requirements
When using an existing grammar:
Example attribution:
Writing Grammars from Scratch
Recommendation: Start with an existing grammar from fresh-plugins/languages and adapt it, rather than writing from scratch.
Minimal Example
Documentation Resources
Sublime Syntax Reference
Complete format specification
Scope Naming Guide
Standard scope names for syntax elements
TextMate Grammars
Additional background information
Working Examples
Real grammars from fresh-plugins
Complete Working Example
From the Templ language pack:Testing and Local Development
Testing with Local Path (Recommended)
The fastest way to test during development:Install from Local Path
Type
package and select “Package: Install from URL”Enter the full path to your language pack directory:Check for Errors
Open command palette and run “Show Warnings”Look for grammar parse errors or missing files
Alternative: Manual Installation
Validation
Always validate before publishing:Troubleshooting
Debugging Commands
Common Issues
Syntax highlighting not working
Syntax highlighting not working
Possible causes:
-
Grammar uses
extendsdirective - Most common issue. Fresh doesn’t support grammar inheritance.- Check logs for
Failed to parse grammar - Find a standalone grammar or manually merge the base grammar
- Check logs for
-
Wrong file extension format - Use
["py"]not[".py"] -
Incorrect grammar file path - Check that the path in
package.jsonmatches the actual file location
LSP server not starting
LSP server not starting
Debugging steps:
-
Verify server is installed:
-
Check LSP logs:
-
Test server manually:
- Check LSP registry - Verify correct command and args at microsoft.github.io/language-server-protocol
Formatter not working
Formatter not working
Debugging steps:
-
Verify formatter is installed:
-
Test formatter manually:
-
Check formatter documentation - Ensure you’re using correct arguments
- Some formatters need stdin:
["-"] - Others need file path:
["--write"](path added automatically)
- Some formatters need stdin:
- Check Fresh logs for formatter errors
Package validation fails
Package validation fails
Common validation errors:
- Invalid JSON - Use a JSON validator or editor with schema support
-
Missing required fields:
- Invalid schema URL - Copy the exact URL from working examples
Publishing
Once your language pack is tested and working:Submit to Registry
User Installation
After your package is in the registry, users can install it:Examples
Solidity
Minimal example - just grammar and basic config
Templ
Complete self-contained grammar with no external dependencies
Hare
Systems language with LSP integration
Fresh Plugins Registry
Browse all published language packs
Next Steps
Plugin Development
Learn how to build plugins with custom functionality
Sublime Syntax Docs
Master the grammar format
LSP Specification
Understand the Language Server Protocol
Example Grammars
Study working language packs