Supercollider and Vim (SCVim) in OSX

After a while struggling with the supercollider editor, which for me has an issue with lots and lots of windows floating around the window, I decided to move to another editing environment to code SuperCollider.There are several options for this, such as using TextMate with sc bundle(https://github.com/sbl/scmate.tmbundle), but I wanted to have a more simple platform.

Then there was ”VIM’ and SCVim. (for more options : http://supercollider.sourceforge.net/wiki/index.php/Systems_interfacing_with_SC)

I will explain a bit how to make a proper install in OSX. (Lion, 10.7.2 at the moment of this posting)
First of all, I normally compile SC from the latest source using git. (for more information about download the latestSC source codes: http://supercollider.sourceforge.net/developers/)
In the source folder, there already is the editor source for SCVIM in the editor folder.
Go to the folder /yourSCSourcedirectory/editor/scvim.
If you want to compile scvim seperate, using those command

cmake ..
make
sudo make install

Then your scvim is located in /usr/local/bin/scvim (to see where your scvim is located: type this in terminal ‘which scvim’)
I assume that your SuperCollider is located in /Applications/SuperCollider, which by default this newly compiled supercollider should be there,
scvim is working by an application called ‘sclangpipe_app,’ which makes possible to run sclang.
When you run scvim, it automatically opens up this sclangpipe_app and this should be able to link all your SCClassLibrary and library files.
In your folder, you see the library files such as libsclang.dylib.
(In the official SuperCollider, you don’t see this so that you can skip this part) and those files should be symlinked to sclangpipe.
To do so, type this in your terminal

cd /usr/local/lib; sudo ln -s <build-dir>/SuperCollider/lib* 

There is another problem with scvim + sclangpipe_app.

When you run scvim on your terminal, your sclangpipe_app is not entirely loading SCClassLibrary, which somehow doesn’t work properly.
So that you need to execute sclangpipe_app seperate from scvim.
In order to do so, I use shell script that automaticallt does this job.
This is the example.

#!/bin/bash
open -a "iTerm.app"
  killall sclang
  /usr/local/bin/sclangpipe_app -l /Applications/SuperCollider&
  sleep 0.5
  open -a "iTerm.app" /usr/local/bin/scvim

I saved this file as ‘scvimsc’ and did ‘chmod +x scvimsc’ to make it executable, and put it into the folder /usr/local/bin/ .
Then what you need to do is in terminal, just type

scvimsc

Then it will automatically open both scvim and sclangpipe_app in a proper way.

 

Optional use of iIerm2 for scvim

I use iTerm2.app(free application) instead of default osx terminal, because I like the way it can do window management.
I wanted to put both ‘post window’ and ‘editing window’ on ‘one window’ so that I do not need to have several windows floating around.
In order to do that, you need to use apple script instead of shell script to set up this.
This is the apple script that I use.

tell application "iTerm"
activate
  -- my project workspace
  set myterm to (make new terminal)
  tell myterm
  launch session "sclang"
  set number of rows to 150
  set number of columns to 40
  tell the last session to write text "killall sclang"
  tell the last session to write text "/usr/local/bin/sclangpipe_app -l /Applications/SuperCollider"
  tell i term application "System Events" to keystroke "d" using command down
  tell the last session to write text "scvim"
  set number of columns to 100
  set number of rows to 10
  end tell

I saved it as an application called ‘iscvim.app’ (from the apple script editor) and put it into /Applications/
So that I can only execute this application to open up iTerms, and scvim, and sclang together in one window!

In theory, this compiling process should be all to make scvim to happen. But surely there is an issue with library links.
But for now all are working fine with some lines on terminal, and can be solved with premade script to make things work.

A nice part of using vim is not only ‘window management’ but also using plugin for VIM. such as snippets for supercollider.
I will get back to this subject some day.
any remarks and commends and questions are welcome.