Map Unknown File Types to Languages
Get syntax highlighting for custom file extensions by mapping them to known languages
Out of the box, Zed can recognize most common languages based on a file’s extension. It knows to both apply JavaScript syntax highlighting and start a JavaScript language server if the file has .js as its extension.
Zed will treat files with extensions it doesn’t recognize, such as .jsm, as plaintext files. However, you can tell Zed to treat these files as ones it understands.
Temporary Override
Use the language selector (command palette → language selector: toggle → JavaScript) to temporarily override a file’s language.
Drawback: This is only a temporary override. Zed will forget about this association the moment you close the file.
Persistent Mapping
To persist this association, configure a mapping via the file_types setting in your settings.json:
{
"file_types": {
"JavaScript": ["*.jsm"]
}
}Now, every time you open a .jsm file, it will be treated as a .js file.
More Examples
file_types supports glob patterns:
{
"file_types": {
"JavaScript": ["*.mjs", "*.cjs", "*.jsm"],
"Markdown": ["*.mdx"],
"JSON": [".eslintrc", "*.jsonc"],
"YAML": ["*.yml", ".yamllint"]
}
}Best Practice
It is always best to first browse Zed’s extension store (command palette → zed: extensions) to see if direct support for your language already exists. If it does not, file_types is a great workaround to get syntax highlighting and language server support for custom file extensions.