Skip to content
GetMikrosPublic

About

Language server and plugins for the MIDL protocol language

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

midl-lsp

Editor support for MIDL, the Mikros interface definition language (MIKSPEC-0024). It lives outside the mikros repository on purpose: MIKSPEC-0023 makes editor integrations a non-goal there.

Path What it is
server/ midl-lsp, the language server, built on midlc's analysis API
tree-sitter-midl/ Tree-sitter grammar and highlight query (used by Zed)
editors/zed/ Zed extension: the grammar, queries, and a shim that starts midl-lsp
editors/textmate/ TextMate bundle (used by JetBrains IDEs; also VS Code's layout)
editors/jetbrains/ Plugin for JetBrains IDEs (IntelliJ IDEA, RustRover, CLion, ...), 2025.2 and later

Server

It provides these features:

  • diagnostics from every parse and check error
  • go to definition and find references
  • hover with the kind, the full name and the doc comments
  • document outline and workspace symbols
  • completion: keywords, built-in types, the names in scope, the declarations of a qualified library, and object types and rights inside handle<...>
  • rename for declarations, members, methods and parameters (not for libraries or enum and bits members; see the limits below)

It reads every .midl file under the workspace folders, then overlays the open buffers. It reruns midlc::analysis::analyze over all of them on every change, because libraries in different folders use each other. A file opened outside every workspace folder brings in its own folder. If that folder is named after a library, such as mikros.fs, the folders next to it come in too.

cargo build --release          # target/release/midl-lsp
cargo install --path server    # or put it in ~/.cargo/bin
cargo test

Until the midlc tooling commits are pushed, server/Cargo.toml uses the mikros checkout next to this repository (../mikros). Cargo builds midlc into this repository's target/ and never into mikros's. After they are pushed, switch to the git dependency in the comment there.

Limits that come from midlc

  • A lexical error, such as a bad integer or an unterminated string, stops the analysis of that file.
  • A declaration that fails to parse disappears from the index, along with all of its members. Names that use it get a "not declared" error.
  • Uses of enum and bits members in constants are not indexed, so those members cannot be renamed and their references are not found.
  • Diagnostics are points in midlc. The server widens each one to the token at that point.

Zed

Zed builds the grammar from a git commit, so editors/zed/extension.toml has to name a commit that contains tree-sitter-midl/. For local development:

  1. Commit the repository.
  2. In extension.toml, set [grammars.midl] as follows:
    • repository = "file:///path/to/midl-lsp" (this checkout)
    • rev = that commit's hash
  3. In Zed, run zed: install dev extension and pick editors/zed.
  4. Put midl-lsp on the PATH, or set it in Zed's settings: {"lsp": {"midl-lsp": {"binary": {"path": "/path/to/midl-lsp"}}}}.

After editing tree-sitter-midl/grammar.js:

cd tree-sitter-midl && npx tree-sitter-cli@0.25.10 generate
scripts/sync-queries.sh   # copies highlights.scm into the Zed extension

JetBrains IDEs

The plugin works in any JetBrains IDE from 2025.2 on that has the built-in LSP client (IntelliJ IDEA, RustRover, CLion, PyCharm, and so on). Highlighting comes from the TextMate bundle in editors/textmate, which ships next to the plugin's jar.

Gradle builds against a locally installed IDE, so nothing has to be downloaded. It looks for one, 2025.2 or later, in the usual install folders:

OS Folders searched
macOS /Applications, ~/Applications
Linux Toolbox (~/.local/share/JetBrains/Toolbox/apps), /opt, /opt/jetbrains, /usr/local, /usr/share, /usr/lib, /snap
Windows %ProgramFiles%\JetBrains, %LOCALAPPDATA%\Programs, Toolbox (%LOCALAPPDATA%\JetBrains\Toolbox\apps)

If it finds several, it takes IntelliJ IDEA first, then RustRover, CLion, GoLand, PyCharm, WebStorm, and the others, and the newest build of that product. To choose one yourself, set platformPath to its install folder, with -PplatformPath=... or in ~/.gradle/gradle.properties.

Gradle needs JDK 21 or later. Any JDK works, including the JetBrains Runtime bundled with the IDE (<ide>/jbr, or <ide>.app/Contents/jbr/Contents/Home on macOS):

cd editors/jetbrains
export JAVA_HOME=/path/to/jdk-21
./gradlew runIde        # a sandboxed IDE with the plugin
./gradlew buildPlugin   # build/distributions/midl-jetbrains-0.1.0.zip

runIde starts the IDE that was found or named. The zip from buildPlugin installs into any supported IDE, not only that one.

To install the zip, go to Settings | Plugins | ⚙ | Install Plugin from Disk. The plugin finds the server in this order:

  1. the path set in Settings | Languages & Frameworks | MIDL
  2. midl-lsp on the PATH
  3. ~/.cargo/bin/midl-lsp

About

Language server and plugins for the MIDL protocol language

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages