SCNVim - A NeoVim frontend for SuperCollider

Thanks, finally that did work! I remember a line in my earlier init.vim that specified the path to sclang, but David left it out of the lua config guide…

1 Like

EDIT: nvm, figured it out! was missing the return statement in the required files, because I had blindly copied them over from some vimrc. I’ll leave the post here for posterity or in case it helps other newbies like me:

SC seems to work, finally, but passing configs to scnvim somehow still doesn’t… this might be my being new to lua and not quite understanding what path the require function requires from (I’ve gone over the doc a few times already lol)

If anybody can quickly spot an obvious misunderstanding, I’d be very grateful…
This is how I set up my config:
1 – .config/nvim/init.lua - requires things in
2 —.config/nvim/lua/namespace/plugins.lua — which in turn, from within packer.use’s config key, requires files in
3 ---- .config/nvim/lua/namespace/config/scnvim.lua, which contains the the actual require’scnvim’ call and the Example config (GitHub - davidgranstrom/scnvim: Neovim frontend for SuperCollider.).

My guess is that either the config = require’namespace.config.scnvim’ in packer, or the require’scnvim’ in the config.scnvim file don’t get through properly, but I’m not sure how I’d find out which one or what to do about it…

Thanks in advance!

well I jinxed it! Now yes, I can get the modules to require correctly … but sc again won’t start, same error as before This is with or without out the Example config.
I tried setting the sclang path too, which didn’t make a difference, so I removed it again. now inspecting the config gives me
sclang = { args = {} }. I assume this defaults to $PATH, as the doc says… but if not, this may be the culprit?

(Intermittently, there was also an error to do with the mappings, which is also odd, because they are the default ones from the Example config)

Tomorrow I’ll try to maybe delete the packer_compiled.lua file, maybe some poor confused setting got stuck in there. Other than that, I’m at my wits end, just like the people in the monty python confuse-a-cat sketch. So I would be thankful for any pointers…

i started to play around with vimR too and at some point also got the assert error “Could not start sclang process”…
found out that it expects user configurations related to PATH in a file called .zshenv.

Thanks, but by now I’ve gone back to just using the macos terminal to make sure it’s not a vimr issue… and currently I can’t even find a .zshenv file on my computer, just the zshrc. Is it supposed to be in the same directory as zshrc?

I’ll try to do a clean, minimal install of the same config from scratch on another machine some time in the coming days and see what happens… if that doesn’t work, I’ll probably raise it as an issue on github.

it should be in your home-directory. you can create it yourself and declare your additions to $PATH there. But on my machine it always worked with nvim started from the terminal with .zshrc. if you get stuck with your config you could also consider switching from packer to vim-plug.

finally got it to work yesterday! It seems like a packer/lua-related newbie misunderstanding after all - solved the issue by modelling my packer config after David’s.

Anyway, takeaways to help others with similar troubles:

  1. It seems like this will cause trouble for packer: use {'someplugin', config = require'myconfig'}
    instead, write use {'someplugin', config = function() require'myconfig' end}.
  2. in the require'scnvim'.setup(), it helps to include sclang = {cmd = '/path/to/sclang'}
    and also ensure_installed = true.

Hi @davidgranstrom @madskjeldgaard ,

I am building setup where people can connect to tmux inside rasberry pi over ssh and share same sclang instance, same buffer using instant.nvim and show output using scnvim-tmux pane. Problem now is that every time new sncvim instance inside different neovim is launched independent sclang is created. E.g. in tidal-vim its easy to achieve this because input is just forwarded to specfic ghci repl inside tmux pane. So u can open multiple tmux panes/windows and send to same ghci repl running tidal. However with scnvim there is server/client architecture but I am pretty sure its possible to send to same sclang. If source code needs to be changed I would appreciate some guidlines where to start and I am gonna try to implement this myself, because I know its very specific case.

Thanks

3 Likes

Hi @qaciwq,

Sounds like an interesting idea! As you noted, the architecture of scnvim is a bit different and the sclang process is launched and controlled by the nvim instance.

It should be possible to implement a client/server model where several nvim clients communicates with the same sclang instance by using the extensions API. You would need to overwrite some of the default module implementations. I would perhaps start with the scnvim.sclang module and the start function. It could also be helpful to review the API documentation to get an overview of the project.

In the original scvim plugin there is a ruby script that launches the sclang process and creates a pipe (socket) for stdin, it should be possible to use this approach with tmux and then you would not need the scnvim-tmux plugin either since stdout would be redirected to the tmux pane.

Good luck!

3 Likes

Hi @qaciwq,
have you found a way to achieve what you have described here?
I made a similar question in the tmux email list.
@igormpc have found the plugin iron.vim we are guessing it could be of some help.

There’s also this video tutorial that explain how to use the autocommand from the vim api. It looks interesting.

1 Like

hi @skmecs,

I didint change scnvim to write to same sclang yet. But after checking the code its 100% possible. I let u know when I do it. So far we been playing with tidal writing to same ghci. And for supercollider just connecting to same tmux instance. That way its more like using several mouses at the same time :slight_smile: only one user can interact at a time. For tidal instant.nvim works really great so by that logic its gonna work for scnvim too. I am adding picture below to illustrate working setup.

https://imgur.com/a/SQqljFo

Basically I wrote script where several panes are created in local tmux session and each ones ssh to rasberry pi and launches specific tmux script based on who is connecting. One for tidal, other for supercollider etc… U can see that in a picture. I am not using any nested tmux session because it becomes mess really fast. Also u need to edit different file with instant.nvim. I recommend creating one folder per user and putting file there.

Here is tmux local script which craetes panes and ssh into server then launches specific script e.g. attach, scnvim or tidal. Those scripts checks if its first user then it initiates setup. If setup is already initiated then it just connects. Thats the gist of it.

#!/bin/zsh

session="livepi"
user="$(whoami)$(cat /etc/hostname)"
window=$user

tmux has-session -t $session &> /dev/null

if [ $? != 0 ]
 then
	 tmux new-session -s $session -n $window -d
	 tmux set status off
	 tmux setw -g pane-active-border-style fg=colour233,bg=#b294bb
	 tmux send-keys -t $session:$window.1 "ssh pi" C-m
	 tmux send-keys -t $session:$window.1 "scnvim" C-m
	 tmux split-window -v -t $session
	 tmux send-keys -t $session:$window.2 "ssh pi" C-m
	 tmux send-keys -t $session:$window.2 "cd $user" C-m
	 tmux send-keys -t $session:$window.2 "attach $user 'tidal'" C-m
	 tmux split-window -h -t $session
	 tmux send-keys -t $session:$window.3 "ssh pi" C-m
	 tmux send-keys -t $session:$window.3 "repl" C-m
	 tmux select-pane -t $session:$window.1
fi

tmux attach -t $session

Also make sure to make paswordless login with ssh. U can do that with putting public ssh key into pi and running ssh-agent on local computers.

1 Like

Hi again.
I managed to send a command to a remote scnvim instance through ssh and nvim remote. But only :SCNvimStart :SCNvimHelp etc. I wonder if that could be a way to send something like sclang.send( ().play )

1 Like

I’ve found a way. Using Instant + HyperDisCo

My user-case was livecoding together with peers.

1 Like

I am trying to :SCNvimStart automatically when I open a supercollider file in nvim and am definitely doing something incorrectly but am currently stumped as to what that is…I have

autocmd FileType supercollider :SCNvimStart<CR>

in my init.vim currently and it results in a lot of errors (see photo below), can someone let me know what I am doing wrong and how to do this properly?

this works for me:

I have the following in lua/config.lua

local api=vim.api
api.nvim_create_autocmd(
  "FileType", {
		pattern = { "SuperCollider" }, command = [[silent! lua require('scnvim').start()]] 
	}
)

and the following in init.vim

lua require('config')
2 Likes

ah cool, hadn’t even started looking at configuring scnvim via lua, this is a good reminder to do so. thank you!

Hi! I wonder if someone tried to map the mac command key for kitty + NeoVim + SCNvim? As I know <D-CR> mapping will only work in MacVim so the question is how to configure it for kitty terminal? It is a bit off-top question but I think this may be the common request for people who are already familiar with cmd+enter or cmd+. and wanted to use those key binds in SCNvim.

Upd: while improving my typing skills in nvim I came to the realization that the commands available in scide are not convenient in nvim and using them is just ruins the main point of using nvim. However, it would be still interesting to learn how to implement cmd key mapping into kitty + nvim because <D-e> still seems useful.

While rummaging at the bottom of both the nvim and sc learning curves I use this addition to the keymaps:

["<F6>"] = map_expr("s.queryAllNodes")

to post a representation of the Server’s current node tree to the post window, or for a graphical variant:

["<F6>"] = map_expr("s.plotTree")

There might be a better way of doing this, but it works for me.

Good morning, all!

I’m struggling to get this working. I’ve got implementation of/connection to the server, but the majority of help files are missing, and I’m not getting any hints or autocompletion with coc. :confused:

I’d be grateful for any direction y’all can give! <3

Edit: I think that the issues stem from being a NixOS user. I look forward to figuring this out. <3

I nevwr tried coc so cannot speak for that but there is some info on using cmp in the wiki for completion and luasnip for snippets etc Additional configuration · davidgranstrom/scnvim Wiki · GitHub