VSCode-supercollider Current State MacOS

Continuing the discussion from SuperCollider VSCode / Language Server Protocol support:

I am not sure what is the current state for support of vscode so apologies for cross-posting this topic but I was wondering if anyone has this working on their machines. My SuperCollider version is 3.13.0.

Settings below:

{
    "supercollider.sclang.cmd": "/Applications/SuperCollider.app/Contents/MacOS/sclang",
    "supercollider.sclang.confYaml": "/Users/konstantinos/Library/Application Support/SuperCollider/sclang_conf.yaml"
}

ERROR:

compiling class library...
	Found 855 primitives.
	Compiling directory '/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/Extensions'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/Singleton'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/Collapse'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/WindowViewRecall'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/Log'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/UnitTest2'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/Deferred'
	Compiling directory '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/LanguageServer'
	numentries = 1386945 / 23100318 = 0.06
	6449 method selectors, 3582 classes
	method table size 23457416 bytes, big table size 184802544
	Number of Symbols 16425
	Byte Code Size 497780
	compiled 626 files in 4.02 seconds
compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
ERROR: Message 'atFail' not understood.
RECEIVER:
   nil
ARGS:
class Log (0x7f97ab697e80) {
  instance variables [19]
    name : Symbol 'Log'
    nextclass : instance of Meta_LogWindow (0x7f97ab6903c0, size=19, set=5)
    superclass : Symbol 'Singleton'
    subclasses : nil
    methods : instance of Array (0x7f97ab698000, size=21, set=5)
    instVarNames : instance of SymbolArray (0x7f97ab698280, size=8, set=2)
    classVarNames : instance of SymbolArray (0x7f97ab698440, size=4, set=2)
    iprototype : instance of Array (0x7f97ab698340, size=8, set=3)
    cprototype : instance of Array (0x7f97ab698500, size=4, set=2)
    constNames : nil
    constValues : nil
    instanceFormat : Integer 0
    instanceFlags : Integer 0
    classIndex : Integer 586
    classFlags : Integer 0
    maxSubclassIndex : Integer 586
    filenameSymbol : Symbol '/Users/konstantinos/Library/Application Support/SuperCollider/downloaded-quarks/Log/Log.sc'
    charPos : Integer 0
    classVarIndex : Integer 55
}
Instance of Function {    (0x7f97ab1901e8, gc=C4, fmt=00, flg=00, set=02)
  instance variables [2]
    def : instance of FunctionDef in Method Meta_Singleton:new
    context : Frame (0x7f97ab0c8988) of Meta_Singleton:new
}
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Object:doesNotUnderstand
		arg this = nil
		arg selector = 'atFail'
		arg args = [*2]
	Meta_Singleton:new
		arg this = <instance of Meta_Log>
		arg name = 'LanguageServer.quark'
		arg settings = [*0]
		var sing = nil
		var classAll = nil
		var created = false
	Meta_LSPConnection:initClass
		arg this = <instance of Meta_LSPConnection>
		var settings = <instance of Event>
	Meta_Class:initClassTree
		arg this = <instance of Meta_Class>
		arg aClass = <instance of Meta_LSPConnection>
		var implementsInitClass = nil
	ArrayedCollection:do
		arg this = [*299]
		arg function = <instance of Function>
		var i = 209
	Meta_Class:initClassTree
		arg this = <instance of Meta_Class>
		arg aClass = <instance of Meta_Object>
		var implementsInitClass = nil
	Process:startup
		arg this = <instance of Main>
		var time = 4.055776793
	Main:startup
		arg this = <instance of Main>
		var didWarnOverwrite = false
^^ ERROR: Message 'atFail' not understood.
RECEIVER: nil

Once on a macos machine I tried this and it worked:

    "supercollider.sclangCmd": "/Applications/SuperCollider.app/Contents/MacOS/sclang -l /Users/smoge/Library/Application Support/SuperCollider/sclang_conf_vscode.yaml",

Try to follow the instructions on GitHub - scztt/vscode-supercollider , install a development version linked in the README file.

Also, vscode requires a lot or ‘permissions’ on your machine. I feel much safer installing a free software build without Microsoft tracking additions. This way, you know what you are using!

Take a look: https://vscodium.com/

1 Like

I know, as asked here (SuperCollider VSCode / Language Server Protocol support - #73 by smoge), I was under the impression that it may be possible to work with a stable version too, so it doesn’t work without a development version?

I have not tried using sclang in vscode, but there are three ways besides the one you mentioned:

Have you tried other methods in the image above?

The other ones are just syntax highlighting, Scott’s extensions is trying to make a LSP (Language Server Protocol) integrated with the IDE. They are not quite the same thing.

1 Like

The only one that provides merely syntax highlighting is the red-ish one, made by “salkin-mada”. The other two are indeed for working SC code, the first is running all code that is enclosed in s.waitForBoot function through the terminal communicating with the sclang executable. The SCVSC is closer to IDE service for SC coding as it offers various coding-related tasks. If the Language Server option of vscode-supercollider could also work with the latest stable instead of the current developer version of SC, which I think is the state now, then it would help to have the server providing information about code-completion syntax highlighting and code analysis so that would be closer to the native IDE.

it’s already close to scide.

it also has more potential to build more tools as it develops

Any hopes for integrating it with other SC versions?

BTW, how did you manage to install the quark, using the Command Pallete >SuperCollider: Update Language Server Quark or manually from the SC IDE?

That sounds very appealing! How does the html help document system work in vscode via both Scott’s extensions and scvsc? If SuperCollider can be used in vscode in the same way as in SC-IDE, then it is worth trying to use one of them, as I often use vscode to find and replace text across files in certain folders.

Sorry to ask this without digging into it myself until I have enough experience with these extensions. Honestly, I tried to use them but gave up. Not so easy to me….

It just works, very similar to scide

1 Like

Thanks for working on this. I’m trying it now and filled a few github bug - the one that is throwing me is this:

in other words, once the quark is installed, it seems to corrupt my SCIDE. Is it not possible to use both on a single machine?

Yes, very impressive!

I’d use two different sclang_conf.yaml files, one for the IDE and one for VSCode.

That shouldn’t be necessary, the typical editor integration behavior is to put editor-specific code in a folder named scide_<editor> and then pass -i <editor> when invoking sclang. For example: https://github.com/supercollider/scel/blob/d8296a9af54d145703726328e22b9e89a08476af/el/sclang-interp.el#L303

this is interesting - I’ll try to find documentation on how to edit these.

I added info to the VSCode extension readme, but just to recap here:

The Document class provides an interface between a given IDE and sclang itself. Unfortunately, the current design expects that each IDE has it’s own version of this class - they have to be swapped out. Launching sclang from the SCIDE causes it to use a built-in Document class for sc-ide, which conflicts with the VSCode one if you have the quark installed.

Ultimately, the design of Document needs to be improved so it can support more than one IDE for a given sclang-conf.yaml file. Until this is fixed, you’ll need to use a separate sclang-conf.yaml file for each IDE (e.g. SCIDE and VSCode) as a few people have suggested.

Refactoring the Document class is extremely worthwhile work for anyone who want to work on a bigger class library task, I’m happy to outline a slightly better implementation that would resolve these problems and clean things up. I don’t think I’ll be able to get to this work soon, there are some basic stability / usability things in the VSCode extension that feel higher priority right now, but if this is a significant blocking issue for a lot of people I’d happily prioritize it a bit higher.

3 Likes

Thanks for this Scott.

I’ve done so (two yaml config files), I am running in new errors, and have documented them on GitHub. I am very appreciative of all the help to bring me up to speed with all of this, and I hope my stumbling will help others get it going. @Sam_Pluta is a great advocate and since he seems to has sorted students on this, maybe he has a fool-proof list for me - he knows how foolish I am indeed :slight_smile:

My advocacy is aspirational. I want it to work because I think this is the best way forward. I got it working for myself, but I didn’t think it was there yet. But this was 6 months ago, so many thanks to @scztt for continuing to work on it. Once it is there, I will switch and never look back.

2 Likes

I tried moving LSPDocument.sc into a scide_vscode directory per moss’ suggestion and it solved the conflict issue for me both with SCNvim and SCIde

@scztt is that sufficient or do changes still need to be made to the Document class?

1 Like

I can also confirm (as semiquaver did) that placing LSPDocument.sc into an editor-specific folder (scide_vscode) works.

Refactoring so that Document is basically a stub at the top of the hierarchy, with subclasses providing the real functionality, is a good idea if it reduces the amount of copy-pasta. But it isn’t strictly necessary just to get it work.

hjh

1 Like