A useless plugin that might help you cope with stubbornly broken tests or overall lack of sense in life. It lets you execute aesthetically pleasing, cellular automaton animations based on the content of neovim buffer.
From the Wiki:
A cellular automaton is a model used in computer science and mathematics. The idea is to model a dynamic system by using a number of cells. Each cell has one of several possible states. With each "turn" or iteration the state of the current cell is determined by two things: its current state, and the states of the neighbouring cells.
There is no pragmatic use case whatsoever. However, there are some pseudo-scientifically proven "use-cases":
<leader>fml
mapping and see it melt.use 'eandrju/cellular-automaton.nvim'
You can trigger it using simple command:
:CellularAutomaton make_it_rain
or
:CellularAutomaton game_of_life
Or just create a mapping:
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
You can close animation window with one of: q
/<Esc>
/<CR>
Using a simple interface you can implement your own cellular automaton animation. You need to provide a configuration table with an update
function, which takes a 2D grid of cells and modifies it in place. Each cell by default consist of two fields:
char
- single string characterhl_group
- treesitter's highlight groupExample sliding animation:
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)
Result: