Zed MATLAB Extension
November 1, 2025 ยท View on GitHub
A MATLAB extension for Zed that provides syntax highlighting and language server support.
Features
- Syntax Highlighting: Full MATLAB syntax highlighting using tree-sitter-matlab
- Language Server Protocol (LSP): Code completion, diagnostics, hover information, and more via the MATLAB Language Server
Installation
The extension can be installed from the Zed extension marketplace. The syntax highlighting will work out of the box. To enable language server features, follow the setup instructions below.
Language Server Setup
To enable LSP features like code completion and diagnostics, you need to install the MATLAB Language Server and make it available in your PATH.
Prerequisites
- Node.js (required to run the language server)
- MATLAB R2021b or later (required for the language server to function)
Installation Steps
-
Clone the MATLAB Language Server repository:
git clone https://github.com/mathworks/MATLAB-language-server ~/.local/share/MATLAB-language-serverOn Windows, use a suitable location like:
git clone https://github.com/mathworks/MATLAB-language-server $env:USERPROFILE\.local\share\MATLAB-language-server -
Build the language server:
cd ~/.local/share/MATLAB-language-server npm install npm run compile npm run package -
Create a wrapper script named
matlab_ls:On Linux/macOS: Create
~/.local/bin/matlab_ls(or another directory in your PATH):#!/usr/bin/env bash exec node "$HOME/.local/share/MATLAB-language-server/out/index.js" "$@"Make it executable:
chmod +x ~/.local/bin/matlab_lsOn Windows: Create
matlab_ls.batin a directory in your PATH (e.g.,C:\Users\<YourUsername>\.local\bin):@echo off node "%USERPROFILE%\.local\share\MATLAB-language-server\out\index.js" %* -
Verify the installation:
matlab_ls --version
Configuration
You can configure the language server by adding settings to your Zed settings.json:
{
"lsp": {
"matlab-language-server": {
"settings": {
"installPath": "/usr/local/MATLAB/R2024a",
"indexWorkspace": true,
"matlabConnectionTiming": "onStart",
"telemetry": false
}
}
}
}
Configuration Options
installPath(string): Path to your MATLAB installation directory (e.g.,/usr/local/MATLAB/R2024aon Linux/macOS, orC:\Program Files\MATLAB\R2024aon Windows)indexWorkspace(boolean): Whether to index the entire workspace for better code intelligence. Default:falsematlabConnectionTiming(string): When to connect to MATLAB. Options:"onStart","onDemand","never". Default:"onDemand"telemetry(boolean): Whether to send telemetry data. Default:true
Troubleshooting
Language server not working
If the language server isn't working:
-
Check that
matlab_lsis in your PATH:which matlab_ls # Linux/macOS where matlab_ls # Windows -
Verify Node.js is installed:
node --version -
Check Zed's log output for error messages (open with
Cmd+Shift+P/Ctrl+Shift+Pand search for "Open Log")
MATLAB installation not found
Make sure the installPath in your settings points to your actual MATLAB installation. The language server needs to locate MATLAB to provide full functionality.
Development
To develop this extension:
- Clone this repository
- Follow the Developing Extensions guide from Zed docs
- Build the extension:
cargo build --release - Install locally for testing
Credits
- MATLAB Language Server by MathWorks
- Tree-sitter MATLAB grammar by acristoffers
License
See LICENSE file.