Deep Learning Based Syntax Detection¶
This feature is optional and disabled by default.
Overview¶
It uses Google's Magika library to detect the file syntax.
Prerequisites¶
- If you are using MacOS, MacOS 14 (Arm64) or later is required. You can run
$ sw_versin terminal to check the OS version. -
If you are using Linux, GLIBC 2.28 or later is required. You can run
$ ldd --versionin terminal to check the GLIBC version on your system. -
Install dependencies.
Run
AutoSetSyntax: Download Dependenciesfrom the command palette. Downloading dependencies may take a while and when it's done, there will be a popup dialogue.If your machine has no access to GitHub...
You can download the dependencies on GitHub basing on your machine's OS and CPU architecture by any means. If you don't know which one to download, run the following command in Sublime Text's console:
import AutoSetSyntax; AutoSetSyntax.plugin.constants.PLUGIN_PY_LIBS_URLDecompress the downloaded
.tar.xzfile intoPackage Storage/AutoSetSyntax/so that the directory structure looks like the following:Package Storage └─ AutoSetSyntax └─ libs-py314@linux_x64 ├── click ├── click-8.1.7.dist-info ├── colorama ├── colorama-0.4.6.dist-info ├── coloredlogs ├── coloredlogs.pth ├── coloredlogs-15.0.1.dist-info ...You can open
Package Storage/AutoSetSyntax/directory by running the following Python code in Sublime Text's console:import AutoSetSyntax; (d := AutoSetSyntax.plugin.constants.PLUGIN_STORAGE_DIR).mkdir(parents=True, exist_ok=True); window.run_command("open_dir", {"dir": str(d)}) -
Enable the feature.
Set
"magika.enabled"totruein AutoSetSyntax's settings. -
Restart Sublime Text.
You may go here to copy some Rust codes and paste them into Sublime Text to test whether this feature works.
Settings Reference¶
magika.enabled¶
| Type | Default |
|---|---|
boolean | false |
Globally enables or disables Magika-based detection.
magika.min_confidence¶
| Type | Default |
|---|---|
number | 0.45 |
The minimum confidence threshold (0.0 to 1.0) required to accept a Magika detection result.
magika.syntax_map.*¶
Settings with the prefix magika.syntax_map. map a Magika output label to one or more syntaxes.
For example, "magika.syntax_map.python": ["scope:source.python"] assigns the Python syntax when Magika detects Python content.
You may also use "=label" to reference another label's mapping, preserving that entry's syntax evaluation order. For example, "magika.syntax_map.rust": ["=cpp"] routes all content detected as Rust through the same syntaxes configured for the cpp label.