Skip to content

Commit b392f22

Browse files
committed
Guarantee availability of Tidal, SuperDirt to Vim Plugin
Switches to a newer branch of the `vim-tidal` plugin that supports auto-starting SuperDirt in a terminal next to the GHCi terminal. This is disabled by default to match the original behaviour, but can be enabled with `let g:tidal_superdirt_enable = 1`. Also updates the `vim-tidal` defaults to use the full paths to the Tidal GHCi instance, Tidal boot file and superdirt-start command within the nix store. This allows for `vim-tidal` to function even outside of the tidal devShell.
1 parent 544f57d commit b392f22

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# TODO: Switch back to `tidalcycles` repo once Vim8 terminal support lands.
2727
# See this PR: https://github.com/tidalcycles/vim-tidal/pull/74
2828
# url = "github:tidalcycles/vim-tidal/master";
29-
url = "github:mitchmindtree/vim-tidal/flupe-vim8-terminal-rebased";
29+
url = "github:mitchmindtree/vim-tidal/superdirt-term";
3030
flake = false;
3131
};
3232
vowel-src = {
@@ -73,11 +73,15 @@
7373
};
7474

7575
# Run `SuperDirt.start` in supercollider, ready for tidal.
76-
superdirt-start = pkgs.writeShellScriptBin "superdirt-start" ''
77-
${supercollider}/bin/sclang \
78-
-l "${superdirt}/sclang_conf.yaml" \
79-
${pkgs.writeText "superdirt-start.sc" "SuperDirt.start;"}
80-
'';
76+
superdirt-start = pkgs.writeShellApplication {
77+
name = "superdirt-start";
78+
runtimeInputs = [supercollider];
79+
text = ''
80+
${supercollider}/bin/sclang \
81+
-l "${superdirt}/sclang_conf.yaml" \
82+
${pkgs.writeText "superdirt-start.sc" "SuperDirt.start;"}
83+
'';
84+
};
8185

8286
# Installs SuperDirt under your user's supercollider quarks.
8387
superdirt-install = pkgs.writeShellScriptBin "superdirt-start" ''
@@ -94,10 +98,31 @@
9498
pname = "vim-tidal";
9599
version = "master";
96100
src = inputs.vim-tidal-src;
97-
# Patch the default GHCI with our `tidal` instance.
98-
# TODO: Update `vim-tidal` to use an env var by default or something instead.
99-
# Would be much cleaner than a patch with might conflict with future commits.
100-
patches = [./patch/vim-tidal-ghci.patch];
101+
postInstall = let
102+
# A vimscript file to set Nix defaults for ghci and `BootTidal.hs`.
103+
defaults-file = pkgs.writeText "vim-tidal-defaults.vim" ''
104+
" Prepend defaults provided by Nix packages.
105+
if !exists("g:tidal_ghci")
106+
let g:tidal_ghci = "${ghcWithTidal}/bin/ghci"
107+
endif
108+
if !exists("g:tidal_boot")
109+
let g:tidal_boot = "${inputs.tidal-src}/BootTidal.hs"
110+
endif
111+
if !exists("g:tidal_superdirt_start")
112+
let g:tidal_superdirt_start = "${superdirt-start}/bin/superdirt-start"
113+
endif
114+
'';
115+
in ''
116+
# Prepend a line to `plugin/tidal.vim` to source the defaults.
117+
mv $out/plugin/tidal.vim $out/plugin/tidal.vim.old
118+
cat ${defaults-file} $out/plugin/tidal.vim.old > $out/plugin/tidal.vim
119+
rm $out/plugin/tidal.vim.old
120+
121+
# Remove unnecessary files.
122+
rm -r $out/bin
123+
rm $out/Makefile
124+
rm $out/Tidal.ghci
125+
'';
101126
meta = {
102127
homepage = "https://github.com/tidalcycles/vim-tidal.vim";
103128
license = pkgs.lib.licenses.mit;

0 commit comments

Comments
 (0)