Skip to content

Commit 3f667ee

Browse files
authored
refactor: migrate test suite to Neovim/Lua (#171)
* chore: migrate Ruby version management to mise Replace .tool-versions with mise.toml, pinning to Ruby major version 4 to avoid unexpected breaking changes from future major version bumps. * fix: remove pry and pry-byebug incompatible with Ruby 4 byebug's native extension fails to compile against Ruby 4's updated C API. Neither gem is referenced in the test suite, so they are safe to remove. Also regenerates Gemfile.lock with current compatible versions. * docs: add local development setup instructions Document the mise + bundle install workflow so contributors know how to get a working local environment. * ci: replace ruby/setup-ruby with jdx/mise-action Use mise to install Ruby in CI, keeping the toolchain consistent with local development. Removes the hardcoded ruby-version matrix — the version is now sourced from mise.toml. Also bumps actions/checkout to v6.0.2. * feat: add Neovim/Plenary test infrastructure (PoC + first test) Introduces a Lua-based test suite driven by Neovim headless mode and Plenary.nvim, replacing the broken Vimrunner/MacVim client-server setup. - test/minimal_init.lua: bootstraps Plenary from /tmp and loads the plugin - test/helpers.lua: feedkeys, new_buffer, test_bullet_inserted utilities - test/poc_spec.lua: infrastructure smoke tests - test/bullets_spec.lua: first ported spec (basic bullet insertion) - mise.toml: adds `mise run test` task; no Makefile needed * test: migrate batch 1 specs to Lua/Plenary (wrapping, filetypes, asciidoc) Key learnings captured in test infrastructure: - feedkeys 'tx' exits insert mode; for non-bullet CR tests use two feedkeys calls where the second prefixes 'i' to re-enter insert mode - Non-bullet-line CR is deferred via feedkeys('n') by the plugin; the 'x' flag drains it within the first call, leaving normal mode on the new line - vim.wait() exits insert mode — do not use it between feedkeys calls - startinsert! is not synchronous from Lua — cannot bridge feedkeys calls - set formatoptions= + comments= in minimal_init and per-test to prevent Neovim's '#' comment-continuation from corrupting test buffers - nested dot bullet test (asciidoc) passes in Neovim — pending mark removed * test: migrate batch 2 specs to Lua/Plenary (alphabetic, renumber, checkboxes) Additional learnings added to minimal_init.lua: - set noexpandtab globally to prevent user config leaking \t → spaces - new_buffer() positions cursor at last line, so tests navigating from line 1 must prefix 'gg' before their first motion - expandtab contamination affects <C-t> indent tests; fixed globally * test: migrate batch 3 specs to Lua/Plenary (bullets, nested_bullets) Completes full test suite migration — all 63 tests passing. Additional learnings: - set expandtab=false + shiftwidth/tabstop=4 in before_each for indent tests - visual mode selection is re-entered by plugin after </> ops; subsequent operations stay in visual — no <Esc> needed between chained motions - A<CR><CR> in one feedkeys call handles the empty-bullet deletion case (both CRs fire while in insert mode, second deletes the empty bullet) - .strip in Ruby tests hides trailing "- " (with space); Lua tests assert the actual content including the trailing space - mid-test config changes (e.g. g:bullets_enable_roman_list) work by setting the global between separate feedkeys calls * test: review and fix test accuracy * chore(mise): add neovim * ci: run lua tests in github actions * chore: remove ruby tests * chore: add dprint and formatting tasks * refactor: format lua tests * fix: include yaml in dprint * fix(dprint): include all supported file types * chore: format README * chore: check formatting * chore: add git hooks tooling
1 parent c19ff40 commit 3f667ee

33 files changed

Lines changed: 1854 additions & 2355 deletions

.github/workflows/test.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@ name: Test
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88
workflow_dispatch:
99

1010
jobs:
11-
test:
12-
11+
fmt:
12+
name: Check Formatting
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Checkout Code
17-
uses: actions/checkout@v6.0.2
16+
- name: Checkout Code
17+
uses: actions/checkout@v6.0.2
1818

19-
- name: Install system dependencies
20-
run: sudo apt install vim-gtk3 xvfb
19+
- name: Set up tools via mise
20+
uses: jdx/mise-action@v4.0.1
2121

22-
- name: Set up Ruby via mise
23-
uses: jdx/mise-action@v4.0.1
22+
- name: Check formatting
23+
run: mise run fmt:check
24+
25+
test:
26+
name: Run Tests
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v6.0.2
2432

25-
- name: Install gems
26-
run: bundle install
33+
- name: Set up tools via mise
34+
uses: jdx/mise-action@v4.0.1
2735

28-
- name: Run headless tests
29-
run: xvfb-run -a bundle exec rspec
36+
- name: Run Lua tests
37+
run: mise run test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
doc/tags
22
vendor/
3-
spec/examples.txt
43
doc/tags

.rspec

Lines changed: 0 additions & 2 deletions
This file was deleted.

.rubocop.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

Gemfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 46 deletions
This file was deleted.

README.md

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
![Bullets.vim](img/bullets-vim-logo.svg)
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4+
45
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors-)
6+
57
<!-- ALL-CONTRIBUTORS-BADGE:END -->
68

79
> :information_source: Looking for help/maintainers https://github.com/dkarter/bullets.vim/issues/126
@@ -23,6 +25,7 @@ Renumbering lines:
2325
# Installation
2426

2527
### With Vim 8.1+ native package manager:
28+
2629
Clone into
2730

2831
`.vim/pack/plugins/start`
@@ -35,8 +38,7 @@ Make sure to include `packloadall` in your `vimrc`.
3538
Plug 'bullets-vim/bullets.vim'
3639
```
3740

38-
Then source your bundle file and run `:PlugInstall`.
39-
41+
Then source your Vim config and run `:PlugInstall`.
4042

4143
# Usage
4244

@@ -306,20 +308,20 @@ let g:bullets_checkbox_partials_toggle = 0
306308

307309
# Mappings
308310

309-
* Insert new bullet in INSERT mode: `<cr>` (Return key)
310-
* Same as <cr> in case you want to unmap <cr> in INSERT mode (compatibility depends on your terminal emulator): `<C-cr>`
311-
* Insert new bullet in NORMAL mode: `o`
312-
* Renumber current visual selection: `gN`
313-
* Renumber entire bullet list containing the cursor in NORMAL mode: gN
314-
* Toggle a checkbox in NORMAL mode: `<leader>x`
315-
* Demote a bullet (indent it, decrease bullet level, and make it a child of the previous bullet):
316-
+ NORMAL mode: `>>`
317-
+ INSERT mode: `<C-t>`
318-
+ VISUAL mode: `>`
319-
* Promote a bullet (unindent it and increase the bullet level):
320-
+ NORMAL mode: `<<`
321-
+ INSERT mode: `<C-d>`
322-
+ VISUAL mode: `<`
311+
- Insert new bullet in INSERT mode: `<cr>` (Return key)
312+
- Same as <cr> in case you want to unmap <cr> in INSERT mode (compatibility depends on your terminal emulator): `<C-cr>`
313+
- Insert new bullet in NORMAL mode: `o`
314+
- Renumber current visual selection: `gN`
315+
- Renumber entire bullet list containing the cursor in NORMAL mode: gN
316+
- Toggle a checkbox in NORMAL mode: `<leader>x`
317+
- Demote a bullet (indent it, decrease bullet level, and make it a child of the previous bullet):
318+
- NORMAL mode: `>>`
319+
- INSERT mode: `<C-t>`
320+
- VISUAL mode: `>`
321+
- Promote a bullet (unindent it and increase the bullet level):
322+
- NORMAL mode: `<<`
323+
- INSERT mode: `<C-d>`
324+
- VISUAL mode: `<`
323325

324326
Disable default mappings:
325327

@@ -345,34 +347,25 @@ Just add above to your .vimrc
345347

346348
# Testing
347349

348-
The test suite is written using vimrunner. It is known to run on macOS with MacVim installed, and on travis. Your vim must have `+clientserver` and either have its own GUI or in a virtual X11 window.
350+
The test suite is written in Lua and runs under Neovim with [Plenary](https://github.com/nvim-lua/plenary.nvim).
349351

350352
## Local Development Setup
351353

352-
This project uses [mise](https://mise.jdx.dev) to manage the Ruby version. Install it, then run:
354+
This project uses [mise](https://mise.jdx.dev) to install Neovim. Install mise, then run:
353355

354356
```sh
355357
mise install
356-
bundle install
357358
```
358359

359360
## Running Tests
360361

361-
On your mac run:
362-
363-
```sh
364-
bundle exec rspec
365-
```
366-
367-
On linux:
362+
Run the full test suite with:
368363

369364
```sh
370-
bundle install
371-
xvfb-run bundle exec rspec
365+
mise run test
372366
```
373367

374-
You should see a Vim window open which will run each test, same general idea as
375-
Capybara integration testing. ❤️
368+
The test task runs Neovim headlessly and downloads Plenary to `/tmp/plenary.nvim` on first run.
376369

377370
# TODO
378371

@@ -385,11 +378,11 @@ Capybara integration testing. ❤️
385378
- [x] reset numbers (user selects numbered bullets 3-5 and copies to middle of document, then reselects and resets them to 1-3)
386379
- [x] check if plugin initialized and don't load if it did
387380
- [x] allow <C-cr> for return without creating a bullet (only possible in GuiVim
388-
unfortunately)
381+
unfortunately)
389382
- [x] check if user is at EOL before appending auto-bullet - they may just want to
390383
- [x] attempt to keep the same total bullet width even as number width varies (right padding)
391384
- [x] detect lists that have multiline bullets (should have no empty lines between
392-
lines).
385+
lines).
393386
- [x] add alphabetic list
394387
- [x] support for intelligent alphanumeric indented bullets e.g. 1. \t a. \t 1.
395388
- [x] change nested outline levels in visual mode
@@ -406,9 +399,7 @@ Capybara integration testing. ❤️
406399
[![Hashrocket logo](https://hashrocket.com/hashrocket_logo.svg)](https://hashrocket.com)
407400

408401
Bullets.vim is kindly supported by [Hashrocket, a multidisciplinary design and
409-
development consultancy](https://hashrocket.com). If you'd like to [work with
410-
us](https://hashrocket.com/contact-us/hire-us) or [join our
411-
team](https://hashrocket.com/contact-us/jobs), don't hesitate to get in touch.
402+
development consultancy](https://hashrocket.com). If you'd like to [work with us](https://hashrocket.com/contact-us/hire-us) or [join our team](https://hashrocket.com/contact-us/jobs), don't hesitate to get in touch.
412403

413404
## Contributors ✨
414405

Rakefile

Lines changed: 0 additions & 7 deletions
This file was deleted.

committed.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
subject_capitalized = false
2+
style = "conventional"
3+
subject_length = 72

0 commit comments

Comments
 (0)