Skip to content

Commit 2194318

Browse files
committed
Languages (sclang): Add davidgranstrom/scnvim
scnvim is a Neovim frontend for SuperCollider. Tracking Issue: jordanisaacs#33
1 parent 7888bab commit 2194318

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed

docs/release-notes/rl-0.1.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ https://github.com/MonaMayrhofer[MonaMayrhofer]:
7878
https://github.com/volfyd[volfyd]:
7979

8080
* Add support for https://github.com/ellisonleao/gruvbox.nvim
81+
82+
https://github.com/mraethel[mraethel]:
83+
84+
* Add support for https://github.com/davidgranstrom/scnvim[davidgranstrom/scnvim]

flake.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@
171171
plugin-glow-nvim.url = "github:ellisonleao/glow.nvim";
172172
plugin-glow-nvim.flake = false;
173173

174+
# SCNvim
175+
plugin-scnvim.url = "github:davidgranstrom/scnvim";
176+
plugin-scnvim.flake = false;
177+
174178
# Plenary (required by crates-nvim)
175179
plugin-plenary-nvim.url = "github:nvim-lua/plenary.nvim";
176180
plugin-plenary-nvim.flake = false;

modules/languages/default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ in {
1919
./markdown.nix
2020
./plantuml.nix
2121
./tidal.nix
22+
./sclang.nix
2223
./html.nix
2324
];
2425

modules/languages/sclang.nix

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
with lib;
7+
let
8+
cfg = config.vim.languages.sclang;
9+
in {
10+
options.vim.languages.sclang = {
11+
enable = mkEnableOption "SuperCollider language support and plugins";
12+
postwin = {
13+
highlight = mkOption {
14+
description = ''Use syntax colored post window output'';
15+
type = types.bool;
16+
default = true;
17+
};
18+
auto_toggle_error = mkOption {
19+
description = ''Auto-toggle post window on errors'';
20+
type = types.bool;
21+
default = true;
22+
};
23+
scrollback = mkOption {
24+
description = ''The number of lines to save in the post window history'';
25+
type = types.int;
26+
default = 5000;
27+
};
28+
horizontal = mkOption {
29+
description = ''Open the post window as a horizontal split'';
30+
type = types.bool;
31+
default = false;
32+
};
33+
direction = mkOption {
34+
description = ''Direction of the split: top, right, bot, left'';
35+
type = types.enum [
36+
"top"
37+
"right"
38+
"bot"
39+
"left"
40+
];
41+
default = "right";
42+
};
43+
float = {
44+
enable = mkOption {
45+
description = ''Use a floating post window'';
46+
type = types.bool;
47+
default = false;
48+
};
49+
};
50+
};
51+
editor = {
52+
force_ft_supercollider = mkOption {
53+
description = ''Treat .sc files as supercollider. If false, use nvim's native ftdetect'';
54+
type = types.bool;
55+
default = true;
56+
};
57+
highlight = {
58+
type = mkOption {
59+
description = ''Highlight flash type: flash, fade or none'';
60+
type = types.enum [
61+
"flash"
62+
"fade"
63+
"none"
64+
];
65+
default = "flash";
66+
};
67+
flash = {
68+
duration = mkOption {
69+
description = ''The duration of the flash in ms'';
70+
type = types.int;
71+
default = 100;
72+
};
73+
repeats = mkOption {
74+
description = ''The number of repeats'';
75+
type = types.int;
76+
default = 2;
77+
};
78+
};
79+
fade = {
80+
duration = mkOption {
81+
description = ''The duration of the flash in ms'';
82+
type = types.int;
83+
default = 375;
84+
};
85+
};
86+
};
87+
signature = {
88+
float = mkOption {
89+
description = ''Show function signatures in a floating window'';
90+
type = types.bool;
91+
default = true;
92+
};
93+
auto = mkOption {
94+
description = ''Show function signatures while typing in insert mode'';
95+
type = types.bool;
96+
default = true;
97+
};
98+
};
99+
};
100+
statusline = {
101+
poll_interval = mkOption {
102+
description = ''The interval to update the status line widgets in seconds'';
103+
type = types.float;
104+
default = 1.0;
105+
};
106+
};
107+
};
108+
109+
config = mkIf (cfg.enable) {
110+
vim.startPlugins = [
111+
"scnvim"
112+
];
113+
vim.luaConfigRC.scnvim = nvim.dag.entryAnywhere ''
114+
local scnvim = require 'scnvim'
115+
local map = scnvim.map
116+
local map_expr = scnvim.map_expr
117+
118+
scnvim.setup({
119+
keymaps = {
120+
['<M-e>'] = map('editor.send_line', {'i', 'n'}),
121+
['<C-e>'] = {
122+
map('editor.send_block', {'i', 'n'}),
123+
map('editor.send_selection', 'x'),
124+
},
125+
['<CR>'] = map('postwin.toggle'),
126+
['<M-CR>'] = map('postwin.toggle', 'i'),
127+
['<M-L>'] = map('postwin.clear', {'n', 'i'}),
128+
['<C-k>'] = map('signature.show', {'n', 'i'}),
129+
['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
130+
['<leader>st'] = map('sclang.start'),
131+
['<leader>sk'] = map('sclang.recompile'),
132+
['<F1>'] = map_expr('s.boot'),
133+
['<F2>'] = map_expr('s.meter'),
134+
},
135+
136+
postwin = {
137+
highlight = ${boolToString cfg.postwin.highlight},
138+
auto_toggle_error = ${boolToString cfg.postwin.auto_toggle_error},
139+
scrollback = ${toString cfg.postwin.scrollback},
140+
horizontal = ${boolToString cfg.postwin.horizontal},
141+
direction = '${cfg.postwin.direction}',
142+
float = {
143+
enabled = ${boolToString cfg.postwin.float.enable},
144+
},
145+
},
146+
147+
editor = {
148+
force_ft_supercollider = ${boolToString cfg.editor.force_ft_supercollider},
149+
highlight = {
150+
type = '${cfg.editor.highlight.type}',
151+
flash = {
152+
duration = ${toString cfg.editor.highlight.flash.duration},
153+
repeats = ${toString cfg.editor.highlight.flash.repeats},
154+
},
155+
fade = {
156+
duration = ${toString cfg.editor.highlight.fade.duration},
157+
},
158+
},
159+
signature = {
160+
float = ${boolToString cfg.editor.signature.float},
161+
auto = ${boolToString cfg.editor.signature.float},
162+
},
163+
},
164+
165+
statusline = {
166+
poll_interval = ${strings.floatToString cfg.statusline.poll_interval},
167+
}
168+
})
169+
'';
170+
};
171+
}

0 commit comments

Comments
 (0)