Tidal NeoVim Plugin Modeled after SCNVim

Tidal Club,

I posted in another thread that I preferred a different method of interaction with Tidal in my vim instance, so I wrote a plugin for neovim modeled after the excellent SCNvim , and took the relevant bits from the tidalvim plugin to integrate it with tidal.

I posted it here - GitHub - john-d-murphy/tidalnvim: Neovim Plugin For TidalCycles

After install and startup of both supercollider and tidal, your neovim instance will look something like this:

I've been running with this for the past few weeks and barring a few bugs (the way that the ghci prompt is displayed / running a block of code from the last line of the buffer), it seems to be working well enough that I can pass it off to the community in its alpha state for bug reports and pull requests.

As an added bonus, since everything is now in neovim, and there's no need to start a tmux instance/etc., you can start everything up with a script. My local one looks like this:



# Get the Project Directory - from https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
PROJECT_DIRECTORY="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

# Go to the project directory so all relative paths are appropriately set

# Source the vim environment bootstrap when neovim starts
/usr/bin/nvim -c ":source environment.vim"


" Startup File that's very specific to the environment and files that live
" within the project. It's not the best, but it gets the workspace into
" a place where it's ready to make sound, and it does so in a local and
" reproducable way.


" Environment Settings that don't need to wait
let g:tidalnvim_configuration_file = getcwd() . "/tidal/boot_tidal.hs"

" TODO: Ensure that the yaml file handles the relative path
let g:scnvim_sclang_library_configuration_file = getcwd() . "/supercollider/sclang_conf.yaml"

" Ex Commands to Start Environment After NVim Startup
function! LoadEnvironment(timer)
    :args ./tidal/composition.tidal
    :args ./supercollider/supercollider_start.sc

    :call tagbar#CloseWindow()

    " Initialize Tidal
    :b composition.tidal
    :call tidalnvim#tidal#open()
    :call tidalnvim#postwindow#close()

    " Initialize SuperCollider
    :b supercollider_start.sc
    :0 " Go to the first line in the startup file (hacky)
    :call scnvim#sclang#open()
    :call scnvim#send_block()
    :call scnvim#postwindow#close()

    :sleep 250m "Wait for flicker to finish

    " Hacky but it'll work - call the appropriate
    " manual commands to split the post windows and make them visible on the right side
    :call tidalnvim#postwindow#open()
    :wincmd l "Move Right
    :wincmd l "Move Right
    :sp #7
    :wincmd h "Move Left
    :b composition.tidal

    " Run the Command to Organize the SuperCollider Status Windows
    :silent !./organize_windows.sh


" Function to Wait for NVim Startup
function! WaitForLoad()
    let timer = timer_start(50, 'LoadEnvironment')

:call WaitForLoad()

This is obviously very specific for my environment and project setup, but the idea of a timer to wait and commands to start and move your windows around should get you pretty far if you want to adopt this style - it took me an afternoon to figure out the semantics, so hopefully I can save people some time!

Let me know if you have any questions and what bugs you find - hopefully I'll be able to reproduce them and fix them quickly and get this into a usable state.



This looks like a great setup - I've dabbled with tidalvim briefly in the past, but found it a little hard to control, this looks significantly more inline with what I would expect.
Nice that you don't have the tmux dependency either - will give it a try when I get a chance :slight_smile: