close
Skip to content
CLOUDWERX-DEVPublic

About

NeoVim Dojo!

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

NVIM.DOJO: learn Neovim and LazyVim in your browser

Learn Neovim and LazyVim in your browser. No install, no config, nothing to break.

It's a small game wrapped around a real modal editor. You get eight short levels that teach the stuff you actually use every day, a free play sandbox, belts, achievements, and a few colorschemes to unlock. Live at dojo.cloudwerxlab.com.

What you learn

Level Topic Keys
1 Modes i a o Esc
2 Moving around h j k l w b gg G
3 Search and undo / n N x u Ctrl+r
4 Save and quit Ctrl+s :w :q :wq :q!
5 Yank, delete, put yy dd p P v V
6 The spacebar Which-Key, Space e, Space Space, Space /
7 Splits and buffers Space |, Space -, Ctrl+h/j/k/l, H L, Space b d
8 Git and terminal LazyGit (Space g g), floating terminal (Ctrl+/)

Level 9 is a free play sandbox with everything turned on.

Every level has a par keystroke count. Beat it and you get a bonus.

It's a real editor, not a quiz

The engine is a pure reducer, one key in and the next editor state out. Normal, Insert, Visual, Visual Line, Command and Search modes all work, and it follows Vim's rules where they matter:

  • a whole insert session undoes in one u
  • Esc steps the cursor back one column
  • j and k remember your column across short lines
  • :q refuses to quit with unsaved changes, and closes a split instead of quitting if you have one
  • Space b d won't close a modified buffer

Yanks and deletes also land on your system clipboard.

Phones and tablets

Touch devices get an on-screen key pad (Vim keys plus a full ABC page), and the mission panel collapses down to your current step. It works, but a real keyboard is a lot nicer for this.

Run it locally

You need Node 20 or newer.

npm install
npm run dev

That serves it on http://127.0.0.1:5173.

Command What it does
npm run dev Dev server
npm run build Typecheck and build to dist/
npm run preview Serve the production build
npm test Run the test suite
npm run typecheck TypeScript only

Tests

The tests play every level start to finish with real key sequences and check each step completes in order. There are also tests for the editor engine itself (motions, undo, visual mode, search, ex commands), the reward and achievement logic, and the save data loader. Around 95 in total, and they run in under a second.

Deploy to Cloudflare

This is a static site, so there's no server to run. I'd use Workers with static assets rather than Pages. Cloudflare is putting new features into Workers, and Pages is basically in maintenance mode now. For a plain Vite app the result is the same, and wrangler.jsonc in this repo is already set up for it.

One time setup

npm install
npx wrangler login

The domain cloudwerxlab.com needs to be on the same Cloudflare account, because the config attaches dojo.cloudwerxlab.com as a custom domain and Cloudflare creates the DNS record for you.

Deploy

npm run deploy

That builds the site and runs wrangler deploy. First deploy takes a minute while the certificate gets issued. Check what would happen without shipping anything with npm run cf:check, and try the real Workers runtime locally with npm run cf:dev.

Deploy on every push (optional)

In the Cloudflare dashboard go to Workers & Pages, create a Worker from the Git repo, and use:

  • Build command: npm run build
  • Deploy command: npx wrangler deploy

What the config does

  • assets.directory serves dist/ straight from the edge
  • not_found_handling: single-page-application sends unknown paths to index.html
  • public/_headers adds a strict Content Security Policy and the usual security headers, and caches the hashed files in /assets forever
  • fonts are bundled (no Google Fonts requests), so the CSP can stay locked to 'self'

If you want a different hostname, change the routes pattern in wrangler.jsonc. If you don't want a custom domain yet, delete the routes block and it'll just live on the workers.dev URL.

Project layout

src/
  engine/       the editor: one file per mode, plus motions, windows, undo, git, terminal
  data/levels/  one file per level
  hooks/        game state and saved progress
  components/   editor UI and game UI
  tests/        level playthroughs and engine tests
public/         favicon and Cloudflare _headers

The version number lives in package.json and the UI reads it from there.

Adding a level

Make a new file in src/data/levels/, export a LevelDef, and add it to index.ts. Each step has a check function that looks at the editor state. Then add a playthrough to src/tests/levels.test.ts, which will also tell you if your par count is off.

License

MIT. Made by CLOUDWERX LAB. Digital Food for the Analog Soul.

If it helped you, you can buy me a coffee.

About

NeoVim Dojo!

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages