From 5d6f7dc3f317614526b74c348b0388b6304d7020 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 5 Feb 2023 16:14:25 +0300 Subject: [PATCH] feat: add cellular automaton to visuals --- flake.lock | 17 +++++++++++++++ flake.nix | 6 ++++++ modules/visuals/visuals.nix | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/flake.lock b/flake.lock index ad5afd3..e963131 100644 --- a/flake.lock +++ b/flake.lock @@ -48,6 +48,22 @@ "type": "github" } }, + "cellular-automaton": { + "flake": false, + "locked": { + "lastModified": 1674679594, + "narHash": "sha256-h4KQCf8+GbxWSyZzDny07YFZm7j+aSSfm51lsaK0Ers=", + "owner": "Eandrju", + "repo": "cellular-automaton.nvim", + "rev": "679943b8e1e5ef79aaeeaf4b00782c52eb4e928f", + "type": "github" + }, + "original": { + "owner": "Eandrju", + "repo": "cellular-automaton.nvim", + "type": "github" + } + }, "cheatsheet-nvim": { "flake": false, "locked": { @@ -823,6 +839,7 @@ "alpha-nvim": "alpha-nvim", "bufdelete-nvim": "bufdelete-nvim", "catppuccin": "catppuccin", + "cellular-automaton": "cellular-automaton", "cheatsheet-nvim": "cheatsheet-nvim", "cinnamon-nvim": "cinnamon-nvim", "cmp-buffer": "cmp-buffer", diff --git a/flake.nix b/flake.nix index 49feb34..a1543c7 100644 --- a/flake.nix +++ b/flake.nix @@ -66,6 +66,7 @@ nvimWebDevicons.enable = true; scrollBar.enable = true; smoothScroll.enable = true; + cellularAutomaton.enable = true; lspkind.enable = true; indentBlankline = { enable = true; @@ -429,6 +430,11 @@ flake = false; }; + cellular-automaton = { + url = "github:Eandrju/cellular-automaton.nvim"; + flake = false; + }; + indent-blankline = { url = "github:lukas-reineke/indent-blankline.nvim"; flake = false; diff --git a/modules/visuals/visuals.nix b/modules/visuals/visuals.nix index b00b408..a186378 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -34,6 +34,12 @@ in { description = "enable smooth scrolling [cinnamon-nvim]"; }; + cellularAutomaton.enable = mkOption { + type = types.bool; + description = "enable cellular automaton [cellular-automaton]"; + default = false; + }; + cursorWordline = { enable = mkOption { type = types.bool; @@ -108,6 +114,11 @@ in { then "cinnamon-nvim" else null ) + ( + if cfg.cellularAutomaton.enable + then "cellular-automaton" + else null + ) ]; vim.luaConfigRC.visuals = nvim.dag.entryAnywhere '' @@ -169,6 +180,36 @@ in { then "require('cinnamon').setup()" else "" } + ${ + if cfg.cellularAutomaton.enable + then '' + local config = { + fps = 50, + name = 'slide', + } + + -- init function is invoked only once at the start + -- config.init = function (grid) + -- + -- end + + -- update function + config.update = function (grid) + for i = 1, #grid do + local prev = grid[i][#(grid[i])] + for j = 1, #(grid[i]) do + grid[i][j], prev = prev, grid[i][j] + end + end + return true + end + + require("cellular-automaton").register_animation(config) + + vim.keymap.set("n", "fml", "CellularAutomaton make_it_rain") + '' + else "" + } ''; }; }