5. Syntax Highlighter and Color Settings Page
The first level of syntax highlighting is based on the lexer output, and is provided by SyntaxHighlighter
. A plugin can also define color settings based on ColorSettingPage
so the user can configure highlight colors.
Define a Syntax Highlighter
The SimpleSyntaxHighlighter
class extends SyntaxHighlighterBase
. As recommended in Color Scheme Management, the Simple Language highlighting text attributes are specified as a dependency on one of standard Intellij Platform keys. For the Simple Language, define only one scheme.
Define a Syntax Highlighter Factory
The factory provides a standard way for the IntelliJ Platform to instantiate the syntax highlighter for Simple Language files. Here, SimpleSyntaxHighlighterFactory
subclasses SyntaxHighlighterFactory
.
Register the Syntax Highlighter Factory
Register the factory with the IntelliJ Platform in the plugin configuration file using the com.intellij.lang.syntaxHighlighterFactory
extension point.
Run the Project with Default Colors
Open the example Simple Language properties file (test.simple
) in the IDE Development Instance. The colors for Simple Language Key, Separator, and Value highlighting default to the IDE Language Defaults for Keyword, Braces, Operators, and Strings, respectively.
Define a Color Settings Page
The color settings page adds the ability for users to customize color settings for the highlighting in Simple Language files. The SimpleColorSettingsPage
implements ColorSettingsPage
.
It is supported to group related attributes like operators or braces by separating the nodes with //
, e.g.:
Register the Color Settings Page
Register the Simple Language color settings page with the IntelliJ Platform in the plugin configuration file using the com.intellij.colorSettingsPage
extension point.
Run the Project
Run the project by using the Gradle runIde
task.
In the IDE Development Instance, open the Simple Language highlight settings page: . Each color initially inherits from a Language Defaults value.