VS Code Extension
The Folio VS Code extension adds language support for .folio templates: syntax highlighting, formatting, and an LSP for autocomplete and diagnostics.
Features
- Syntax highlighting for
.folioand.pdf-templatefiles - Code formatting with
Shift+Alt+F - LSP-powered autocomplete, hover, and diagnostics
- Compile a template to generated PHP with a single command
Install from a GitHub Release
The easiest way to install the extension is to grab the latest .vsix from the GitHub Releases page.
- Download the
folio-pdf-*.vsixasset from the latestvscode-v*release. - In VS Code, open the Extensions panel (
Ctrl+Shift+X). - Click the ... menu → Install from VSIX....
- Select the downloaded
.vsixfile.
Or install from the command line:
bash
code --install-extension folio-pdf-0.2.0.vsixRequirements
- PHP 8.3 or later
- The Folio PHP package installed in your workspace (
composer require mohammadraufzahed/folio)
The extension looks for the language server automatically in these locations:
- A configured absolute path (
folio-pdf.lsp.serverPath) <workspace>/lsp/lsp.php(when working on Folio itself)<workspace>/vendor/mohammadraufzahed/folio/lsp/lsp.php<workspace>/vendor/folio/pdf/lsp/lsp.php
Configuration
Set Folio as the default formatter for .folio files:
json
{
"[folio]": {
"editor.defaultFormatter": "folio-pdf.folio-pdf",
"editor.formatOnSave": true
}
}Extension Settings
| Setting | Default | Description |
|---|---|---|
folio-pdf.format.enable | true | Enable formatting |
folio-pdf.format.indentSize | 4 | Indentation width |
folio-pdf.lsp.enable | true | Enable the language server |
folio-pdf.lsp.phpPath | php | Path to the PHP binary |
folio-pdf.lsp.serverPath | '' | Absolute path to lsp/lsp.php |
Commands
Folio PDF: Format Document— format the active templateFolio PDF: Compile Template— compile the template to PHPFolio PDF: Restart Language Server— restart the LSP
Install from Source
Clone the repository.
Open the
vscode-extensiondirectory.Install dependencies and compile:
bashnpm install npm run compilePackage the extension:
bashnpm run packageInstall the generated
.vsixfile through VS Code's Extensions panel.
Development Mode
- Open
vscode-extensionin VS Code. - Press
F5to launch the Extension Development Host. - Open any
.foliofile to test highlighting and formatting.