sonic-pi icon indicating copy to clipboard operation
sonic-pi copied to clipboard

Possible to use with external editor?

Open TomasHubelbauer opened this issue 6 years ago • 16 comments

Hey, I have just discovered this software and love the idea! However, the entire UI of the app, I am not a fan of. What I am a fan of is VS Code. I think what would be a really nice touch is if Sonic Pi was able to listen on a file for changes so people could use an editor of their choice. Is something like that possible today?

And if not, I don't know if you are familiar with Language Server Protocol? I think it could be used to provide sort of a daemon which many IDEs could communicate with (much easier to support just LSP than to try and please everyone who uses different IDEs with different extensibility models).

I have not done this before, but if you'd be down to mentor me on the Sonic Pi's side of things, I'd like to try and implement a super basic PoC of LSP to see if I could get VS Code to talk to Sonic Pi over LSP's extension messages. Not only should it be able to support listening on file changes, but also provide code completion and even the waveform data if a VS Code plugin to display them was implemented (which wouldn't be very hard to do given that VS Code supports WebView based extensions now so we could just render waveform data to a canvas).

Please let me know what you think of the idea.

TomasHubelbauer avatar May 12 '18 15:05 TomasHubelbauer

it's a great idea, please implement.

arun6202 avatar May 28 '18 02:05 arun6202

@TomasHubelbauer , look around this post: https://in-thread.sonic-pi.net/t/running-sonic-pi-code-from-atom-text-editor/1193 Maybe there is a way for VS Code without changing Sonic-Pi Sourcecode.

vlrmprjct avatar Jun 23 '18 07:06 vlrmprjct

@telekommander Way cool, thank you, I will definitely check that out!

TomasHubelbauer avatar Jun 23 '18 19:06 TomasHubelbauer

@TomasHubelbauer ,
Great! Please let me know if you have a working prototype or version.

vlrmprjct avatar Jun 24 '18 13:06 vlrmprjct

I believe enabling external editors to work with Sonic Pi should be easy and with minimal changes to Sonic Pi.

If Sonic Pi provides these global (operating system wide) keyboard shortcuts:

  1. Play
  2. Stop
  3. Reload script from the last loaded or saved script file

Since I cannot work with the local editor due to its messy font sizes and non-intuitive choice of shortcut keys, I have developed a short AutoHotkey script that sends these commands to Sonic Pi.

In my case, since to my knowledge there is no way to tell Sonic Pi to reload saved script, I am simply sending a "Select All then Paste" keyboard input to it.

It works, but I wish Sonic Pi had these globally available keys.

DannyBen avatar Jul 13 '18 19:07 DannyBen

For sublime there's https://packagecontrol.io/packages/Sonic%20Pi

A5308Y avatar Sep 08 '18 12:09 A5308Y

Anything new here?

RadW2020 avatar Jun 18 '19 17:06 RadW2020

FWIW I didn't end up pursuing this

TomasHubelbauer avatar Jun 18 '19 17:06 TomasHubelbauer

This seems to do the trick: https://marketplace.visualstudio.com/items?itemName=mactkg.sonic-pi

kylegrover avatar Oct 29 '19 01:10 kylegrover

Related discussion going on in #2371.

bhrutledge avatar May 14 '20 10:05 bhrutledge

Until the extension is ready, you can use sonic-pi-cli along with custom tasks and keyboard shortcuts.

Here's a gist with all the files you need to change. I've explained everything in this post.

ninest avatar Jun 26 '20 08:06 ninest

Any news on this?

piscespieces avatar Nov 17 '20 02:11 piscespieces

@piscespieces - The (volunteer, besides Sam Aaron) core team have been focussed on preparing the latest beta/release of Sonic Pi - so no further development in the VS code extension as yet.

ethancrawford avatar Nov 17 '20 02:11 ethancrawford

any work on the language server protocol? I am using this with (neo)vim

Chaitanyabsprip avatar Mar 01 '21 18:03 Chaitanyabsprip

For (n)vim there is https://github.com/lilyinstarlight/vim-sonic-pi

marcofeltmann avatar Feb 28 '22 16:02 marcofeltmann

For my most basic need (use an interface for coding that I'm used to) the solution could be as simple as hot-reloading changes to files on the disk into the Sonic Pi editor. I can live with doing [Alt + R] and [Alt + S] in the Sonic Pi editor, but what breaks me every time is all the other shortcuts that throw sticks between my spokes (including the ones I can't use because I'm using a German keyboard).

https://wiki.seeedstudio.com/Use_External_Editor/

So why not do it like the Arduino IDE does it? User can enable "Use external editor", which makes the internal editor read only and hot-reloads changes from disk. Would be a huge step forward to enable alternative editors.

Background: the Arduino IDE suffers from the same approach as Sonic Pi: it is great to learn coding from scratch as a first-timer because it simplifies the interface a lot. But as soon as you reach a certain level, the reduced functionality limits your creativity. And for people who are fond of coding but used to more elaborate editors, it feels like a cage. The Arduino project did two steps to bridge the gap between professionals and beginners: first they allowed external editors, then they introduced arduino-cli, which completely de-couples the build-system from the editor. Would be great to have this for Sonic Pi as well.

Arduino references:

frederikheld avatar Jul 21 '22 11:07 frederikheld