|
| 1 | +# rubiks-cube.nvim |
| 2 | + |
| 3 | +A playable Rubik's cube inside Neovim — isometric ASCII render, full move set in Singmaster notation, a timer, and best-time persistence. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Neovim **0.10+** (uses `vim.uv`) |
| 10 | +- `termguicolors` enabled (recommended; falls back to cterm approximations otherwise) |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +### lazy.nvim |
| 15 | + |
| 16 | +```lua |
| 17 | +{ |
| 18 | + "xiangnongWu2233/rubiks-cube.nvim", |
| 19 | + cmd = "Rubikscube", |
| 20 | + opts = {}, -- or pass any config table; see below |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +### packer.nvim |
| 25 | + |
| 26 | +```lua |
| 27 | +use { |
| 28 | + "xiangnongWu2233/rubiks-cube.nvim", |
| 29 | + cmd = "Rubikscube", |
| 30 | + config = function() require("rubikscube").setup({}) end, |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +```vim |
| 37 | +:Rubikscube |
| 38 | +``` |
| 39 | + |
| 40 | +## Features |
| 41 | + |
| 42 | +- All 18 standard moves: face turns (`U D L R F B`) + cube rotations (`x y z`), each in CW/CCW form |
| 43 | +- Built-in timer with pause/resume on `<Space>` |
| 44 | +- Solve detection — flash + popup with time, move count, and personal best |
| 45 | +- Persistent best time stored at `stdpath("data")/rubikscube/best.json` |
| 46 | +- Floating window by default; configurable to open in current buffer, split, or vsplit |
| 47 | +- Fully configurable keymaps; any binding can be disabled with `false` |
| 48 | + |
| 49 | +Inside the cube buffer: |
| 50 | + |
| 51 | +| Key | Action | |
| 52 | +|---|---| |
| 53 | +| `u` / `U` | U face CW / CCW | |
| 54 | +| `d` / `D` | D face CW / CCW | |
| 55 | +| `l` / `L` | L face CW / CCW | |
| 56 | +| `r` / `R` | R face CW / CCW | |
| 57 | +| `f` / `F` | F face CW / CCW | |
| 58 | +| `b` / `B` | B face CW / CCW | |
| 59 | +| `x` / `X` | rotate whole cube around R axis | |
| 60 | +| `y` / `Y` | rotate whole cube around U axis | |
| 61 | +| `z` / `Z` | rotate whole cube around F axis | |
| 62 | +| `<Space>` | start / pause timer | |
| 63 | +| `s` | scramble (default 20 random moves) | |
| 64 | +| `<CR>` | reset to solved (clears timer) | |
| 65 | +| `?` | toggle help popup | |
| 66 | +| `q` | quit | |
| 67 | + |
| 68 | +Lowercase = clockwise face turn (Singmaster notation); uppercase = prime (counter-clockwise). |
| 69 | + |
| 70 | +## Configuration |
| 71 | + |
| 72 | +Default: |
| 73 | + |
| 74 | +```lua |
| 75 | +require("rubikscube").setup({ |
| 76 | + keymaps = { |
| 77 | + -- Face turns: configure the lowercase letter; uppercase auto-binds the prime. |
| 78 | + U = "u", D = "d", L = "l", R = "r", F = "f", B = "b", |
| 79 | + -- Cube rotations: same convention. |
| 80 | + x = "x", y = "y", z = "z", |
| 81 | + -- Actions. |
| 82 | + scramble = "s", |
| 83 | + reset = "<CR>", |
| 84 | + timer = "<Space>", |
| 85 | + quit = "q", |
| 86 | + help = "?", |
| 87 | + -- Any entry above may be set to `false` to skip the binding entirely. |
| 88 | + }, |
| 89 | + scramble_length = 20, -- moves applied by the scramble action |
| 90 | + persist_best = true, -- set false to disable writing best.json (reads still work) |
| 91 | + open_in = "float", -- "float" | "current" | "split" | "vsplit" |
| 92 | +}) |
| 93 | +``` |
| 94 | + |
| 95 | +## Colors |
| 96 | + |
| 97 | +Sticker colors are exposed as the highlight groups: |
| 98 | + |
| 99 | +``` |
| 100 | +RubiksW white |
| 101 | +RubiksY yellow |
| 102 | +RubiksO orange |
| 103 | +RubiksR red |
| 104 | +RubiksG green |
| 105 | +RubiksB blue |
| 106 | +``` |
| 107 | + |
| 108 | +Override any of them from your colorscheme — they're set with `default = true`, so user overrides survive a plugin reload: |
| 109 | + |
| 110 | +```vim |
| 111 | +highlight RubiksO guibg=#ff8800 guifg=#000000 |
| 112 | +``` |
| 113 | + |
| 114 | +## Commands |
| 115 | + |
| 116 | +| Command | Description | |
| 117 | +|---|---| |
| 118 | +| `:Rubikscube` | Open the cube (no-op if a cube is already open) | |
0 commit comments