Minimal syntax highlighter for OpenFOAM dictionary files in VS Code.
Available on Visual Studio Marketplace and installable locally (see instructions below).
Supported files
The extension auto-detects several filenames with no manual file association; common files such as controlDict, decomposeParDict, and fvSolution are included in the built-in list. You can also add custom filenames via extension settings (see below). The extension supports C-style comments, delimiters, strings, and OpenFOAM-style dictionary entries.
It is a design choice to use exact filename matching to identify OpenFOAM dictionary files, as opposed to relying on file extensions or more complex heuristics. Also, the file list is not exhaustive and can be extended by users as needed, as their field of expertise may require highlighting of additional dictionary files than the ones provided by default.
You can add your own dictionary file names via extension settings (in settings.json), using the following configuration:
- Setting key:
openfoamDictHighlight.additionalFilenames - Type: array of strings
- Match mode: exact file name, case-insensitive match
Example:
{
"openfoamDictHighlight.additionalFilenames": [
"mySolverDict",
"regionProperties",
"combustionProperties"
]
}
After changing this setting, the extension reapplies language detection to currently open files. If an open file no longer matches the built-in or configured names, it is reset to plaintext.
Alternative fallback (if you prefer native VS Code association behavior) is to use files.associations, for example:
{
"files.associations": {
"**/mySolverDict": "openfoam-dict"
}
}
Install locally
Option 1: Install unpacked extension folder
- Open VS Code.
- Open Extensions view.
- Select
...(More Actions) ->Install from Location.... - Pick this extension's root folder.
Option 2: Package as VSIX and install
-
Install
vsceby runningnpm install -g @vscode/vscein your terminal. -
From this directory, package this extension with
vsce package -
In VS Code, run
Extensions: Install from VSIX...and select the generated.vsixfile.