diff --git a/docs/release-notes/rl-0.1.adoc b/docs/release-notes/rl-0.1.adoc index aad2ebb..820f401 100644 --- a/docs/release-notes/rl-0.1.adoc +++ b/docs/release-notes/rl-0.1.adoc @@ -78,3 +78,7 @@ https://github.com/MonaMayrhofer[MonaMayrhofer]: https://github.com/volfyd[volfyd]: * Add support for https://github.com/ellisonleao/gruvbox.nvim + +https://github.com/mraethel[mraethel]: + +* Add support for https://github.com/davidgranstrom/scnvim[davidgranstrom/scnvim] diff --git a/flake.lock b/flake.lock index 5bc256e..194e249 100644 --- a/flake.lock +++ b/flake.lock @@ -782,6 +782,22 @@ "type": "github" } }, + "plugin-scnvim": { + "flake": false, + "locked": { + "lastModified": 1687884269, + "narHash": "sha256-z0r8M0L5aZ2ugqjAfHAUPWaVVfn91B7xNG3oXJiIcl0=", + "owner": "davidgranstrom", + "repo": "scnvim", + "rev": "c44d57aeadc4b01888bc10a249f8867df8d1a461", + "type": "github" + }, + "original": { + "owner": "davidgranstrom", + "repo": "scnvim", + "type": "github" + } + }, "plugin-sqls-nvim": { "flake": false, "locked": { @@ -965,6 +981,7 @@ "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-registers": "plugin-registers", "plugin-rust-tools": "plugin-rust-tools", + "plugin-scnvim": "plugin-scnvim", "plugin-sqls-nvim": "plugin-sqls-nvim", "plugin-telescope": "plugin-telescope", "plugin-todo-comments": "plugin-todo-comments", diff --git a/flake.nix b/flake.nix index 9558eb2..6ab5f0e 100644 --- a/flake.nix +++ b/flake.nix @@ -171,6 +171,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; diff --git a/modules/languages/default.nix b/modules/languages/default.nix index 0eea090..dd4087c 100644 --- a/modules/languages/default.nix +++ b/modules/languages/default.nix @@ -19,6 +19,7 @@ in { ./markdown.nix ./plantuml.nix ./tidal.nix + ./sclang.nix ./html.nix ]; diff --git a/modules/languages/sclang.nix b/modules/languages/sclang.nix new file mode 100644 index 0000000..42aed19 --- /dev/null +++ b/modules/languages/sclang.nix @@ -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; + }; + auto_toggle_error = 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 = { + force_ft_supercollider = 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 = { + poll_interval = 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 = { + [''] = map('editor.send_line', {'i', 'n'}), + [''] = { + map('editor.send_block', {'i', 'n'}), + map('editor.send_selection', 'x'), + }, + [''] = map('postwin.toggle'), + [''] = map('postwin.toggle', 'i'), + [''] = map('postwin.clear', {'n', 'i'}), + [''] = map('signature.show', {'n', 'i'}), + [''] = map('sclang.hard_stop', {'n', 'x', 'i'}), + ['st'] = map('sclang.start'), + ['sk'] = map('sclang.recompile'), + [''] = map_expr('s.boot'), + [''] = map_expr('s.meter'), + }, + + postwin = { + highlight = ${boolToString cfg.postwin.highlight}, + auto_toggle_error = ${boolToString cfg.postwin.auto_toggle_error}, + 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.force_ft_supercollider}, + 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.poll_interval}, + } + }) + ''; + }; +}