VSCode-supercollider Current State MacOS

Just a little overview of color related bugs, both in Documentation and otherwise:

  1. Syntax highlighting colors are determined by the supercollider.tmLanguage.json file.
  2. You can see WHY something in the editor is colored the way it is by running the Developer: Inspect Tokens and Scopes command, and then moving the cursor to the code in question. The textmate scopes value should correspond to something in the tmLanguage file, and the foreground color is from your theme (you can see the details of this by running Developer: Color Theme From Current Settings).
  3. Compare SuperCollider highlighting in your theme to that of another language, e.g. Python or Javascript. If something in sclang is being highlighted in a way that seems inconsistent or weird, see if there’s a better TextMate scope to use (this is easy-ish to change in the tmLanguage file). If you feel at all hacker-y, changing the tmLanguage file to find a better TM scope is easy, and making a pull request for a positive fix would be very helpful!
  4. If the highlighting is simply misunderstanding the sclang code (e.g. it’s highlighting isn’t just a wrong color, it’s understanding symbols incorrectly), it’s probably a problem the regex strings in the tmLanguage. Fixing these is a fun hacky evening project, but also tbh very annoying - I’m happy to take PR’s on this but I don’t blame you if you get frustrated. :slight_smile:
  5. Documentation color is a pain in the ass… The frontend.css file maps css selectors for the SuperCollider documentation to colors in the VSCode theme, so the docs match the theme. The vscode colors (things like --vscode-sideBarSectionHeader-foreground) correspond to the colors in your theme (again, Developer: Color Theme From Current Settings will show these). They’re all prefixed by --vscode and dots are converted to -.
  6. I’ve spend VERY little time mapping sclang documentation colors to theme colors. If you see parts of the documentation that don’t match your theme very well, I would love it if you can experiment with the frontend.css colors to see if you can find a better option. The Open Webview Developer Tools command can be helpful here, as it gives you a dev panel for the documentation, which should let you live-edit the CSS. Please try this with a few different themes to make sure the change is legible in a general way.
  7. Code that is displayed in the sc documentation is even worse - SCDoc uses a javascript code component that has it’s OWN syntax highlighting. Ideally, I would set the highlighting of this code panel to something that matches your vscode theme, but I haven’t gotten around to this. If someone figures out a good way to do this, it would be very helpful. I don’t think it’s hard, probably just digging in the documentation a bit.
1 Like

Probably this is not a you problem. Let me know a few specific links in the documentation that result in a white page? Or, if you want to try debugging the vscode plugin yourself - the documentation is literally running on a locally hosted web server, specified in help.ts in the launchServer function. A breakpoint on line 231 should let you see what the HTTP request from the documentation is, and maybe get a clue why it’s failing and resulting in a blank page.

I figured out why this is the case (at least for a couple of cases I am having), though I don’t know the solution. It seems it is because the html file for the help doesn’t exist and the VS Code version of SC doesn’t automake it for you. Weird.

I was making a help file this morning. The help didn’t work - white screen as described by @tremblap above. I opened SCIDE, looked up the help, and it worked. Went back to VSCode and it worked. I had been having the same issue with FluidLabelSet in VSCode. Went into IDE, opened the help, now it is all good in VS Code. In both cases the HTML file didn’t exist in the Help directory until loading in the IDE. What might be the easy fix for this in VSCode? Is there a function that isn’t being run properly?

Sam

just a quick note that I see this in SCNvim when using the String:help method - I get a “file does not exist” or some such error. Completely intermittent, not sure why it works sometimes.

The help browser needs to call into sclang when a link is clicked, to render the target page. It’s not enough to pop up a webpage; there needs to be a link handler. I’m not sure exactly where in SC-IDE code this is done. The sclang GUI HelpBrowser does it with an onLinkActivated function. Probably this just hasn’t been implemented in the VSCode plugin yet.

hjh

Not sure if this will help in your case but evaluating SCDoc.renderAll in SC-IDE as recommended in this post solved the issue for me.

1 Like

Hi there
I just installed the vscode plugin, it’s an amazing development :slight_smile:

In my case it works and it sounds, but I get an annoying error message when pressing Enter to create a new line (video attached)

Did anyone encounter a similar problem?

This is the error message

ERROR: Message 'isOpen' not understood.
RECEIVER:
   nil
ARGS:

PROTECTED CALL STACK:
	Meta_MethodError:new	0x15088ee00
		arg this = DoesNotUnderstandError
		arg what = nil
		arg receiver = nil
	Meta_DoesNotUnderstandError:new	0x150899140
		arg this = DoesNotUnderstandError
		arg receiver = nil
		arg selector = isOpen
		arg args = []
	Object:doesNotUnderstand	0x1501e3e40
		arg this = nil
		arg selector = isOpen
		arg args = nil
	Meta_TextDocumentFormattingProvider:format	0x150995540
		arg this = TextDocumentFormattingProvider
		arg uri = file:///Users/lluissuros/Music/Supercollider/test.scd
		arg tabSize = 4
		arg insertSpaces = true
		var doc = a LSPDocument
		var text = 
{SinOsc.ar(200)}.play;


	a FunctionDef	0x152481540
		sourceCode = "<an open Function>"
	Function:prTry	0x150c2d540
		arg this = a Function
		var result = nil
		var thread = a Routine
		var next = nil
		var wasInProtectedFunc = true
	
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	< FunctionDef in Method LSPConnection:prHandleMessage >
		arg error = <instance of DoesNotUnderstandError>
	< FunctionDef in Method Deferred:then >  (no arguments or variables)
	Routine:prStart
		arg this = <instance of Routine>
		arg inval = 25311.583292792
^^ ERROR: Message 'isOpen' not understood.
RECEIVER: nil


[Error - 22:14:01] Request textDocument/onTypeFormatting failed.
  Message: DoesNotUnderstandError
  Code: -1108578637 

This are my vscode settings

"supercollider.sclang.cmd": "/Applications/SuperCollider.app/Contents/MacOS/sclang",
  "supercollider.sclang.confYaml": "/Users/lluissuros/Library/Application Support/SuperCollider/sclang_conf_vscode.yaml",
  "supercollider.sclang.environment": {},
  "supercollider.sclang.args": [],

As I understand it, the sc-specific code formatter requires a command line tool, sclang-format, by scztt as well.

hjh

After downloading this repository, I did the following in a terminal in vscode, and got an error:

(base) prko@prkoMBP2021 sclang-format-master % cd src    
(base) prko@prkoMBP2021 src % gcc -o cla sclang-format.cpp
sclang-format.cpp:1:10: fatal error: 'SCLexer.h' file not found
#include "SCLexer.h"
         ^~~~~~~~~~~
1 error generated.

I could not find SCLexer.h and the other header files in this repository and the official SuperCollider repository. How could I find that file?

There are cmake files in the repository, suggesting that the build procedure is to use cmake to configure the build, then make (a familiar procedure if you’ve built SC from source). After satisfying the dependencies, this went fine.

But I remembered what is the real problem with the code formatter: it depends on a two-way Pipe method which doesn’t exist in the main SC distribution. It must be an extension that isn’t currently public. So it’s not usable at present and there’s no choice but to disable the formatter for now.

hjh

1 Like

Thanks for the answer @jamshark70, but unfortunately I don’t know what to make with this project at all (Readme doesnt seem to guide me enough, and I would need much more hand holding)

Just in any case, I found a hacky fix to avoid the annoying error in the log, which -I think- is basically disables the SC code formatter, by changing this line to false (I changed it under /Application Support/SuperCollider/downloaded-quarks/LanguageServer/Providers/TextDocumentFormattingProvider.sc)

At this point, it’s moot anyway because of the missing method that’s called in CodeFormatter. I’d suggest to wait until that’s resolved (no idea how long that will take – source code for it isn’t even publicly available for review yet).

IIRC the SuperCollider vscode plugin publishes a setting for the formatter to use; you should be able to disable it here as well.

hjh

1 Like

This worked for me, at least for now. Thanks so much!

1 Like