Skip to content

refactor: replace plenary.nvim with native vim.system/vim.uv (#317) - #330

Merged
rcasia merged 8 commits into
mainfrom
stack/plenary-2-remove-dependency
Sep 5, 2026
Merged

rcasia merged 8 commits into
mainfrom
stack/plenary-2-remove-dependency

Conversation

@rcasia

@rcasia rcasia commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Closes #317, #331, #332

Stacked on #328 — #328 merged to main (squashed) on 2026-09-05; this branch is rebased onto main and now contains only the plenary removal commits.

neotest-java no longer depends on plenary.nvim. The plugin's own code, its unit/integration harness, and its published rockspec no longer reference it — the 189-test suite passes with plenary entirely absent from the unit harness runtimepath.

One honest caveat (caught by CI after rebasing onto main, commit 8bdf2ab): the e2e harness still clones plenary.nvim and puts it on the runtimepath — because neotest itself requires plenary.path/plenary.filetype internally (neotest/lib/file, lib/positions, lib/subprocess). The e2e harness builds a user-like environment by hand (--noplugin -u tests/testrc.vim) instead of via a plugin manager, so it must provide neotest's transitive deps; real users get it automatically (see README). This is neotest's dependency, not ours — once neotest drops plenary upstream, we can too. README.md entries listing plenary under neotest's own dependencies remain correct and untouched.

What changed

Runtime swap (the plenary.nvim usages)

  • build_tool/launcher.lua: default job_runner is now a small vim.system-based implementation, matching the same vim.system usage already established in command/command_executor.lua. Same contract as the old plenary.job-based default (new(opts):start(), command/args/cwd/on_stdout/on_stderr/on_exit) — no callers changed.
  • Fixes launcher.lua: dap.repl left as a truthy error string when nvim-dap isn't installed, would crash on use #332 — latent bug where local _, repl = pcall(require, "dap.repl") left repl as a truthy error-message string when dap.repl isn't installed.
  • util/detect_project_type.lua: default scandir fallback now reuses util/dir_scan.lua's existing vim.uv.fs_scandir-based recursive walk instead of plenary.scandir.
  • Fixes dir_scan.lua: injected test stub permanently pollutes the real scan() for the rest of the process #331 — a real pre-existing bug in dir_scan.lua found while wiring this up: scan() reassigned the module-level iter_dir upvalue instead of using a local, so any test injecting a stub permanently poisoned every later real scan() call in the same process.

luassert removal (plenary's last hold-out use, as a dev/test dep)

  • Converted the remaining ~50 busted-style assertions (assert.is_true/is_false/is_nil/is_not_nil/is_truthy/is_function/are.same) in 7 test files to plain Lua assert(cond, msg) and the project's own tests.assertions.eq helper (already the standard everywhere else; same deep-equality semantics, same argument order as are.same).
  • scripts/minimal_init.lua no longer injects _G.assert = require("luassert").
  • Removed plenary from the Makefile install target and test runtimepath, .github/workflows/luarocks.yml rockspec deps, and tests/performance/path_benchmark.lua's dead plenary comparison sections.

Todo

Test results

  • bash scripts/test after fresh install (without plenary on disk at all): 189/189 passing, 0 fails (same count as before)
  • stylua --check .: clean
  • luacheck lua/neotest-java/... tests/...: 0 warnings, 80 files
  • lua-language-server --check .: clean, 82 files

Mirrors the existing nio.wrap(vim.system) convention from
command/command_executor.lua. The DI seam PR #328 added
(BuildToolLauncher(deps).job_runner) made this a drop-in default swap —
same contract (new(opts):start(), command/args/cwd/on_stdout/on_stderr/on_exit),
no callers changed.

Also fixed the latent dap.repl bug PR #328 documented: a failed
pcall(require, 'dap.repl') left repl as the pcall's truthy error-message
string instead of nil, which would have crashed any repl.clear()/append()
call when dap.repl isn't installed.
…based fallback

Reuses util/dir_scan.lua's existing vim.uv.fs_scandir-based recursive
walk instead of writing new scanning code, filtered to the same build-marker
filenames the old plenary.scandir call cared about.

Also fixes a real latent bug in dir_scan.lua found while wiring this up:
scan() reassigned the module-level iter_dir upvalue instead of using a
local, so an injected test stub (e.g. from test_dir_scan_spec.lua) would
permanently replace the real implementation for every later call to
scan() in the same process -- silently breaking any test that runs
afterwards and calls the real scan() (exactly what happened to this
PR's own new integration tests until this fix).
…ew defaults

Same real-JVM / real-filesystem coverage PR #328 added, now exercising
the new vim.system-backed job runner and dir_scan-based fallback instead
of the old plenary-based defaults.
Nothing in lua/neotest-java/ requires plenary anymore. It's kept as a
dev/test-only dependency (Makefile + scripts/minimal_init.lua) solely to
provide luassert (bundled inside it), used by a handful of specs'
busted-style assertions -- unrelated to the plugin's own runtime.

Updated ARCHITECTURE.md, CONTRIBUTING.md, health.lua, and
tests/testrc.vim (used by the e2e harness, which never needed plenary)
to reflect this. README.md's lazy.nvim snippets still list
nvim-lua/plenary.nvim under nvim-neotest/neotest's own dependencies --
left untouched since that's neotest's own dependency, confirmed by
grepping deps/neotest/lua/neotest/lib/* which genuinely requires
plenary internally.

Closes #317.
…'s eq helper

All remaining busted-style matchers (assert.is_true/is_false/is_nil/
is_not_nil/is_truthy/is_function/are.same) replaced with:
- plain Lua assert(cond, msg) for truthiness/nil checks
- tests.assertions.eq (already the project's standard deep-equality
  helper, used everywhere else) for are.same call sites

Also dropped a stale ---@module "luassert" annotation from
test_positions_discoverer_spec.lua, which used no luassert matchers.

Removes the last reason the test suite needed luassert (bundled inside
plenary.nvim), enabling full plenary removal in the next commits.
With no luassert-style assertions left in the suite, minimal_init.lua no
longer needs to clone plenary.nvim, add it to the runtimepath, or clobber
the global assert with luassert's extension. Same for the Makefile
target. plenary.nvim is now fully absent: not a runtime dependency, not
a dev/test dependency, not referenced anywhere in the repo's code.
…rockspec deps

- tests/performance/path_benchmark.lua: dropped the plenary.path
  comparison sections (dead code now that plenary is not on any
  runtimepath).
- tests/e2e/full_workflow_spec.lua: converted its luassert matchers to
  plain assert() so it at least parses consistently (it is never
  executed - see #333).
- .github/workflows/luarocks.yml: removed plenary.nvim from the
  generated rockspec's dependency list, since it's no longer a runtime
  dependency of this plugin.

Full sweep confirms: 'grep -rn plenary|luassert' across lua/, tests/,
scripts/, .github/, and Makefile returns only a historical comment in
detect_project_type.lua referencing the old implementation.
@rcasia
rcasia force-pushed the stack/plenary-2-remove-dependency branch from 2002f83 to 1e61835 Compare September 5, 2026 14:01
@rcasia
rcasia disabled auto-merge September 5, 2026 14:03
… dependency

The previous commits removed plenary.nvim from the Makefile install
target and tests/testrc.vim entirely. That broke the e2e job: neotest
itself requires plenary.path/plenary.filetype internally
(deps/neotest/lua/neotest/lib/file/init.lua:2, lib/positions,
lib/subprocess), and the e2e harness builds a user-like runtimepath by
hand (--noplugin -u tests/testrc.vim) instead of via a plugin manager
that would resolve neotest's deps for it.

Symptom: the inner nvim crashes on require('plenary.path') when
neotest.lib.file loads, run.lua keeps polling for results that never
arrive, and the job dies at the 5-minute timeout. Reproduced exactly
with:

  nvim --headless --noplugin -u tests/testrc.vim \
    -c "lua print(require('neotest.lib.file').is_dir('.'))"

Fix: restore the plenary clone + runtimepath entry, now explicitly
commented as neotest's transitive dependency, not neotest-java's. The
unit/integration harness (scripts/minimal_init.lua) intentionally keeps
NO plenary - the 189/189 suite passes without it, proving neotest-java's
own code no longer depends on plenary.
@rcasia
rcasia merged commit 71354dd into main Sep 5, 2026
17 checks passed
@rcasia
rcasia deleted the stack/plenary-2-remove-dependency branch September 5, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant