An AI-powered, Prettier-like code formatter for CFML (ColdFusion Markup Language) that runs directly in Visual Studio Code. This extension uses the Google Gemini API to understand and reformat your messy CFML, HTML, and SQL mixed code, producing a clean, consistently formatted version.
Features
- AI-Powered Formatting: Leverages the power of generative AI to understand the structure of your CFML code, including tags, attributes, and sibling relationships (
<cfif>
, <cfelse>
).
- Seamless Integration: Integrates with VS Code's native formatting capabilities.
- Format on Save: Automatically format your CFML files every time you save.
- Context-Aware: Preserves the raw content inside special blocks like
<cfquery>
and <cfscript>
.
- Easy Configuration: Just add your Gemini API key and you're ready to go.
Requirements
You must have a valid Google Gemini API key to use this extension. You can obtain a key for free from Google AI Studio.
Extension Settings
This extension contributes the following settings:
cfml-ai-formatter.apiKey
: Your Google Gemini API Key. This is required.
How to Add Your API Key
- Open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
).
- Type
Preferences: Open User Settings (JSON)
and select it.
- Add the following line to your
settings.json
file:
"cfml-ai-formatter.apiKey": "YOUR_GEMINI_API_KEY_HERE"
- Save the file.
Alternatively, the extension will prompt you to open the settings UI the first time you try to format a file without a key.
Usage
Once the extension is installed and your API key is configured, you can format your CFML code (.cfm
, .cfc
files) in several ways:
- Format Document Command:
- Open a CFML file.
- Open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
).
- Run the "Format Document" command.
- Right-Click Context Menu:
- Right-click inside a CFML file.
- Select "Format Document".
- Format on Save:
- To enable format on save, add the following to your
settings.json
:
"[coldfusion]": {
"editor.defaultFormatter": "your-publisher-name.cfml-ai-formatter",
"editor.formatOnSave": true
}
- Replace
your-publisher-name
with the actual publisher ID you use when publishing.
Disclaimer
This is a proof-of-concept using a powerful AI model. While it aims for Prettier-like idempotency and accuracy, the formatting is non-deterministic by nature. Always review the formatted code.
Enjoy consistently formatted CFML!