Add advanced language features for Csound via custom Tree-sitter–based LSP#42
Add advanced language features for Csound via custom Tree-sitter–based LSP#42PasqualeMainolfi wants to merge 26 commits intocsound:masterfrom
Conversation
|
Just wanted to note that I saw this PR but it came in while I was traveling for holidays. I'm on another trip now so will look at this when I return home in a couple days. Apologies @PasqualeMainolfi for the delay in review! |
|
@PasqualeMainolfi One thing I did want to ask is if you tested this as a Web Extension (i.e., when installed and running in github.dev). I didn't see code to support that but may have just missed it. |
|
No worries. |
There was a problem hiding this comment.
Thank you @PasqualeMainolfi, it's going to be very nice to have this feature. I am going to leave the technical review to @kunstmusik as he is more familiar with these things, but I am concerned that this PR overwrites the project's readme file. This removes all the historical context for the existing project as well as removing valuable information about live-coding and using the UDP server. Would you mind reverting the README to the original master branch version. We can then update accordingly after any merge.
|
I’ve restored the original README to preserve the historical context and existing information. Additionally, I’ve added release notes to the PR, without referencing any version numbers. |
|
Thanks @PasqualeMainolfi - I know Steven is extremely busy right now, but hopefully we can get this merged and into the extension in time for the first release of Csound 7 👍 |
|
I was wondering if there is any approximate timeline available for the release of Csound7. Having a rough idea of the release date would help me plan the remaining work and properly schedule the effort needed to deliver a stable version of the LSP. I am already quite close, and only a few final adjustments are still missing. Thanks in advance for any information you can share. |
|
Good question. I think most of the tasks have been completed at this stage. So it could be in the next few weeks but I don't think any hard deadline has been set. |
src/utils.ts
Outdated
| try { | ||
| await vscode.window.withProgress({ | ||
| location: vscode.ProgressLocation.Notification, | ||
| title: `Installazione Csound LSP (${binaryName})...`, |
There was a problem hiding this comment.
This should be in English to match the rest of the plugin. (I haven't done I18N for vscode plugins before; we could investigate that in a separate PR)
|
@PasqualeMainolfi I ran this in the extension development host. It requested installing the LSP and then reported success in installing the LSP. I checked before and after and CSD and ORC code looks no difference with little syntax highlighting. I did not get any manual entries, autocomplete, etc. I am on MacOS. Unsure if something's gone wrong in installation or what but it's not operating as (I assume) expected.
|
|
I think I have fixed the bugs you showed me. |
|
@PasqualeMainolfi I tried the latest and when I start up the extension host it asks to download a newer version of LSP. I says yet and then it errors:
|
|
Thanks for the report! |
|
One other note, I asked Opus about using tree-sitter in Javascript so that we can use it in the web extension version of this plugin. Looks like compiling to WASM would be an option, which is promising. Looking at this PR, your concern is valid. The PR introduces a Csound Language Server built on a custom Tree-sitter grammar, which typically compiles to native binaries. This would indeed be incompatible with running as a VS Code web extension. The Good NewsYes, Tree-sitter parsers can run in JavaScript/WebAssembly. Tree-sitter supports compiling grammars to WASM, which can then be loaded and run in JavaScript environments (including browsers and VS Code web extensions). How to Make It Work for Web ExtensionsThe tree-sitter-csound grammar would need to be compiled to WASM instead of (or in addition to) native binaries. Here's what's typically required:
Recommendations for the PR
|
|
Yes, I can. |
|
I think we're on the same page, offer what we can in each environment. I think this will work out nicely and users will be happy. :) |
|
Thanks @PasqualeMainolfi it wasn't the vertical line but the issue with the chnget opcode not being recognized. Looks like it's fixed now. 👍 |
|
@kunstmusik you can try the web version now. It’s still a work in progress: at the moment I’ve implemented the basic features such as syntax highlighting, basic completion, and indentation. Diagnostics and injections are still missing, but I’m currently working on them. |
|
I tried the web version and highlighting worked. Looks like command names were updated for desktop but not for web, as trying to render a document ends up with an error. Opus suggests: Looking at the error and the code, the issue is that the PR's LSP server exposes a command The error The ProblemThe PR likely registers CodeLens actions that try to execute
Quick FixYou need to register the missing command in the web extension. Add this to your // ...existing code...
const evalScoCommand = vscode.commands.registerTextEditorCommand(
"extension.csoundEvalSco",
(textEditor: vscode.TextEditor) => {
const content = getEvalText(textEditor);
if (content.trim()) {
csoundWebViewProvider.evalSco(content);
} else {
vscode.window.showWarningMessage("No score code selected or found.");
}
}
);
context.subscriptions.push(evalScoCommand);
// Register the csound.runFile command that CodeLens expects
const runFileCommand = vscode.commands.registerCommand(
"csound.runFile",
async (uri?: vscode.Uri) => {
const editor = vscode.window.activeTextEditor;
if (editor) {
const content = getActiveDocumentContent(editor);
if (content) {
const relativePath = vscode.workspace.asRelativePath(editor.document.uri);
await csoundWebViewProvider.playCsd(content, relativePath);
vscode.commands.executeCommand('csound.webview.focus');
}
} else {
vscode.window.showErrorMessage("No active Csound file to run.");
}
}
);
context.subscriptions.push(runFileCommand);
}
// ...existing code...Additional Commands to ConsiderIf the LSP also uses // Alias for LSP command name
const runFileLspCommand = vscode.commands.registerCommand(
"csound-lsp.run_file",
async () => {
vscode.commands.executeCommand("csound.runFile");
}
);
context.subscriptions.push(runFileLspCommand);
const toAudioFileCommand = vscode.commands.registerCommand(
"csound-lsp.to_audio_file",
async () => {
vscode.window.showInformationMessage(
"Render to audio file is not supported in the web extension."
);
}
);
context.subscriptions.push(toAudioFileCommand);This should resolve the command not found error. The root issue is that the LSP's CodeLens features are triggering commands that weren't registered in the web extension context. |
|
@kunstmusik the web version does not depend on the desktop LSP. The extension has two different entry points. |
|
I just updated here and I can no longer build due to the |
|
@rorywalsh Ok, it is possible! I've added the compiled .wasm so you don't have to build it yourself for this testing phase. Later on, I'll release an npm package so you can install it directly without needing any extra build tools for the wasm. |
|
Thanks @PasqualeMainolfi I can now build locally again, but nothing seems to work. I see no syntax highlighting at all. I wonder if it might be best to try to complete the desktop stuff first, and then in another PR look at the web stuff? The desktop stuff was almost ready for merging as far as I could make out. |
|
@rorywalsh That seems strange. I’ve just tested the latest desktop version and everything works fine on my end. You might want to try downloading the latest desktop version. |
|
Thanks, but where can I download the latest version? I've been building
myself from this PR, and testing that way?
…On Thu, 12 Feb 2026 at 16:43, Pasquale Mainolfi ***@***.***> wrote:
*PasqualeMainolfi* left a comment (csound/csound-vscode-plugin#42)
<#42 (comment)>
@rorywalsh <https://github.com/rorywalsh> That seems strange. I’ve just
tested the latest desktop version and everything works fine on my end. You
might want to try downloading the latest desktop version.
Screenshot.2026-02-12.alle.17.35.45.png (view on web)
<https://github.com/user-attachments/assets/7e307bfb-43dd-457d-b730-c40e793ef511>
—
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUQWGJOYOPNZLG65WBUEYL4LSUTVAVCNFSM6AAAAACQINIOMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQOJSGAZTIMZSG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@rorywalsh update your local repository to the latest commit, rebuild the project, and it should automatically notify you about the new LSP version. |
|
Loos good now with the latest change 👍 |
|
@rorywalsh perfect! |
|
@rorywalsh check the LSP version in the lsp-bin folder, it should be 1.4.6. The web version is separate from the desktop one, so they don't touch each other. I did a fresh test from scratch just to be sure, and it all works fine. Additionally, verify that the
|
|
@rorywalsh If you'd like, feel free to send me the entire script. There might be something breaking the syntax that I'm missing just by looking at the photo. |















Csound vscode
This PR introduces a new Csound extension for Visual Studio Code built on top of a custom Csound Language Server (LSP) and a Csound Tree-sitter grammar specifically designed for Csound.
The extension aims to provide a modern, semantically aware editing experience for Csound users, fully compatible with Csound7.
Key Features
LSP
Editor
Completion & Hover
Commands exposed by the Language Server
The server exposes the following commands:
csound-lsp.run_file— run the current Csound scriptcsound-lsp.to_audio_file— render and save output to an audio filecsound-lsp.open_manual— open the Csound reference manualOffline Manual (Web Preview)
Language Injections
Technical Notes
Future Work
Planned next steps include:
This PR lays the groundwork for a complete and modern Csound development environment in VS Code, aligned with current language-server–based tooling.
Feedback and testing are highly appreciated.