Registering File Type

The first step in developing a custom language plugin is registering a file type associated with the language.

The IDE typically determines the type of a file by looking at its file name or extension. In 2020.2, support for mapping via hashbang is available via hashBangs attribute in com.intellij.fileType extension point.

A custom language file type is a class derived from LanguageFileType, which passes a Language subclass to its base class constructor.

To register a file type, the plugin developer provides a subclass of FileTypeFactory, which is registered via the com.intellij.fileTypeFactory extension point.

NOTE When targeting 2019.2 or later only, using com.intellij.fileType extension point is preferred to using dedicated FileTypeFactory.

Examples: - LanguageFileType subclass in Properties language plugin - Custom Language Support Tutorial: Language and File Type

To verify that the file type is registered correctly, you can implement the LanguageFileType.getIcon() method and verify that the correct icon (see Working with Icons and Images) is displayed for files associated with your file type.

If you want IDEs to show a hint prompting users that your plugin supports a specific file type, see Plugin Recommendations.

To control file type association with the IDE in the operating system, implement com.intellij.openapi.fileTypes.OSFileIdeAssociation (2020.3).