Skip to content

Commit

Permalink
Languages (sclang): Add davidgranstrom/scnvim
Browse files Browse the repository at this point in the history
scnvim is a Neovim frontend for SuperCollider.
Tracking Issue: #33
  • Loading branch information
mraethel committed Sep 7, 2023
1 parent 60950c0 commit 0cf6e89
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/release-notes/rl-0.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ https://github.com/volfyd[volfyd]:
https://github.com/sedlund[sedlund]:

* Add support for https://github.com/jackMort/ChatGPT.nvim[ChatGPT.nvim]. The option <<opt-vim.chatgpt.config>> should be used to configure a command to get an api key. See https://github.com/jackMort/ChatGPT.nvim#configuration for details.

https://github.com/mraethel[mraethel]:

* Add support for https://github.com/davidgranstrom/scnvim[davidgranstrom/scnvim]
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@
plugin-glow-nvim.url = "github:ellisonleao/glow.nvim";
plugin-glow-nvim.flake = false;

# SCNvim
plugin-scnvim.url = "github:davidgranstrom/scnvim";
plugin-scnvim.flake = false;

# Plenary (required by crates-nvim)
plugin-plenary-nvim.url = "github:nvim-lua/plenary.nvim";
plugin-plenary-nvim.flake = false;
Expand Down
1 change: 1 addition & 0 deletions modules/languages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ in
./markdown.nix
./plantuml.nix
./tidal.nix
./sclang.nix
./html.nix
./bash.nix
];
Expand Down
171 changes: 171 additions & 0 deletions modules/languages/sclang.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
config,
lib,
...
}:
with lib;
let
cfg = config.vim.languages.sclang;
in {
options.vim.languages.sclang = {
enable = mkEnableOption "SuperCollider language support and plugins";
postwin = {
highlight = mkOption {
description = ''Use syntax colored post window output'';
type = types.bool;
default = true;
};
autoToggleError = mkOption {
description = ''Auto-toggle post window on errors'';
type = types.bool;
default = true;
};
scrollback = mkOption {
description = ''The number of lines to save in the post window history'';
type = types.int;
default = 5000;
};
horizontal = mkOption {
description = ''Open the post window as a horizontal split'';
type = types.bool;
default = false;
};
direction = mkOption {
description = ''Direction of the split: top, right, bot, left'';
type = types.enum [
"top"
"right"
"bot"
"left"
];
default = "right";
};
float = {
enable = mkOption {
description = ''Use a floating post window'';
type = types.bool;
default = false;
};
};
};
editor = {
forceFtSupercollider = mkOption {
description = ''Treat .sc files as supercollider. If false, use nvim's native ftdetect'';
type = types.bool;
default = true;
};
highlight = {
type = mkOption {
description = ''Highlight flash type: flash, fade or none'';
type = types.enum [
"flash"
"fade"
"none"
];
default = "flash";
};
flash = {
duration = mkOption {
description = ''The duration of the flash in ms'';
type = types.int;
default = 100;
};
repeats = mkOption {
description = ''The number of repeats'';
type = types.int;
default = 2;
};
};
fade = {
duration = mkOption {
description = ''The duration of the flash in ms'';
type = types.int;
default = 375;
};
};
};
signature = {
float = mkOption {
description = ''Show function signatures in a floating window'';
type = types.bool;
default = true;
};
auto = mkOption {
description = ''Show function signatures while typing in insert mode'';
type = types.bool;
default = true;
};
};
};
statusline = {
pollInterval = mkOption {
description = ''The interval to update the status line widgets in seconds'';
type = types.float;
default = 1.0;
};
};
};

config = mkIf (cfg.enable) {
vim.startPlugins = [
"scnvim"
];
vim.luaConfigRC.scnvim = nvim.dag.entryAnywhere ''
local scnvim = require 'scnvim'
local map = scnvim.map
local map_expr = scnvim.map_expr
scnvim.setup({
keymaps = {
['<M-e>'] = map('editor.send_line', {'i', 'n'}),
['<C-e>'] = {
map('editor.send_block', {'i', 'n'}),
map('editor.send_selection', 'x'),
},
['<CR>'] = map('postwin.toggle'),
['<M-CR>'] = map('postwin.toggle', 'i'),
['<M-L>'] = map('postwin.clear', {'n', 'i'}),
['<C-k>'] = map('signature.show', {'n', 'i'}),
['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
['<leader>st'] = map('sclang.start'),
['<leader>sk'] = map('sclang.recompile'),
['<F1>'] = map_expr('s.boot'),
['<F2>'] = map_expr('s.meter'),
},
postwin = {
highlight = ${boolToString cfg.postwin.highlight},
auto_toggle_error = ${boolToString cfg.postwin.autoToggleError},
scrollback = ${toString cfg.postwin.scrollback},
horizontal = ${boolToString cfg.postwin.horizontal},
direction = '${cfg.postwin.direction}',
float = {
enabled = ${boolToString cfg.postwin.float.enable},
},
},
editor = {
force_ft_supercollider = ${boolToString cfg.editor.forceFtSupercollider},
highlight = {
type = '${cfg.editor.highlight.type}',
flash = {
duration = ${toString cfg.editor.highlight.flash.duration},
repeats = ${toString cfg.editor.highlight.flash.repeats},
},
fade = {
duration = ${toString cfg.editor.highlight.fade.duration},
},
},
signature = {
float = ${boolToString cfg.editor.signature.float},
auto = ${boolToString cfg.editor.signature.float},
},
},
statusline = {
poll_interval = ${strings.floatToString cfg.statusline.pollInterval},
}
})
'';
};
}

0 comments on commit 0cf6e89

Please sign in to comment.