Overview

The MUFL language server is a Visual Studio Code (VS Code) extension based on the Language Server Protocol (LSP) created to enhance your editing experience. It provides autocomplete, error-checking (diagnostics), jump-to-definition, and many other language-specific editing features supported in VS Code.

After installing the MUFL language server extension in your VS Code, the extension is automatically enabled when working with MUFL (.mm, .mufl, .mu) files. However, we recommend further configuring the extension in your VS Code settings to best meet your needs.

Extension Configuration

To access the available configuration settings, in VS Code, navigate to Settings > Extensions > mufl language server configuration.

  • Mufl Language Server: Enable Meta - When enabled, the language server compiles MUFL files with the meta stage, enabling compile-time type checking.

Compiling all files with the meta stage (type checking) enabled is usually slower. Alternatively, you can enable type-checking in individual files using pragma syntax in your MUFL files.

  • pragma langserver force_meta - When enabled, the language server compiles the file with the meta stage, even if you’ve disabled meta in the VS Code settings.
  • pragma langserver no_meta - When enabled, the language server compiles the file without meta, even if you’ve enabled meta in the VS Code settings.

  • Mufl Language Server: Environment Variables - To pass environment variables (for example, #$MUFL_STDLIB) to the MUFL compiler as JSON, edit settings.json and add name-value pairs (for example, {'MUFL_STDLIB':'<path_to_mufl_stdlib>'}). By passing an environment variable in the VS Code settings, you can use the variable in your MUFL code. For example, use this approach in config files to pass a path to the MUFL standard library, defining it as an environment variable globally.

  • Mufl Language Server: Path To Meta - Specifies the absolute path to the directory containing the meta.mm type-checking library.

  • Mufl Language Server: Path To Transactions - Specifies the absolute path to the directory containing the transaction.mm and __t_wrapper.mm libraries.

  • Mufl Language Server > Trace: Server - Specifies the level to trace communication between VS Code and the language server.

Keyboard Shortcut

Another useful feature of the MUFL language server is using a keyboard command to enable/disable the meta stage of the compilation.

To create a VS Code keyboard shortcut:

  1. In VS Code, navigate to File > Preferences > Keyboard Shortcuts.
  2. Scroll to the muflLangServer.enableMeta entry.
  3. Edit the keybinding and create your desired key combination.