Using MF2 in editors and IDEs

MessageFormat 2 is a programming language, and as such, it can be helpful to have tooling support in editors and IDEs. The MF2 tools project (not affiliated with Unicode) provides a language server and syntax highlighting grammar that can be used in various editors and IDEs.

This page provides instructions for setting up the MF2 language server in various editors and IDEs.

Features Jump to heading

The MF2 language server and TextMate grammar provide the following features:

  • Syntax and semantic highlighting
  • Diagnostics (syntax errors, early errors)
  • Variable completion
  • Variable rename
  • Go to definition for variables
  • Quick fixes for some errors
  • Formatting

Editors and IDEs Jump to heading

Visual Studio Code Jump to heading

To use the MF2 language server in Visual Studio Code, install the extension from the Visual Studio Code Marketplace.

Install the MF2 extension for Visual Studio Code.

Once installed, the extension will automatically start the language server when a .mf2 file is opened. The extension provides all features available in the MF2 language server.

.input {$pronoun :string}
.input {$name :string}
.match $pronoun
he {{His name is {$name}.}}
she {{Her name is {$name}.}}
* {{Their name is {$name}.}}

screenshot

Syntax highlighting, and formatting

screenshot

Syntax highlighting in Intl.MessageFormat constructor

screenshot

Syntax highlighting in JavaScript template string

screenshot

Variable rename

screenshot

Diagnostics for syntax errors

Other editors and IDEs Jump to heading

The MF2 language server can be used in other editors and IDEs that support the Language Server Protocol. The language server is available in binary form from the MF2 tools releases page.

The TextMate grammar is available in the repository at vscode/syntaxes/mf2.tmLanguage.json.

To configure your editor or IDE to use the MF2 language server and TextMate grammar, follow the instructions for your specific editor or IDE.

On this page