Skip to content

feat: vendor and clean up plenary#3647

Draft
clason wants to merge 38 commits into
masterfrom
feat/neoplen
Draft

feat: vendor and clean up plenary#3647
clason wants to merge 38 commits into
masterfrom
feat/neoplen

Conversation

@clason

@clason clason commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

This started as an procrastination investigation into what we actually use from Plenary, and which part of it can easily be replaced with current Neovim API. This is obviously not ready to merge yet, but I'm putting this here in the open now that Plenary is going to be archived, in case people want to follow along (and pitch in) as I keep chipping at it.

I think I have picked all of the low-hanging fruit, but there's obviously much more to be done. Roughly in order of difficulty:

  •  the class.lua module is only used in the (now renamed) async_job telescope module to define a bunch of pipes objects. These should just be created directly, but care is required to adapt the downstream usage.
  • the scandir.lua is only used in one place: to list files in a directory previewer. As I don't use that myself, I have been hesitant to convert it (should be a straightforward replacement using a variant of vim.system('ls'), so that's another nice, self-contained, project). As far as I can tell, the directory preview is only used in the telescope-file-browser extension, which isn't actively maintained and arguably too far out of scope for a core extension.
  • the path.lua module usages are straightforward to replace with vim.fs and vim.fn calls; there's just quite a few of them. But this can be done file by file, so it's a good "fifteen minute project" when someone is bored. A first step could also be is to just replace suitable functions with wrappers of existing (libuv or Nvim ) API and prune then-unused internal functions. EDIT: In particular, the OO wrapper should be removed and replaced by flat string manipulation functions (and moved, if necessary, to utils.lua).
  • the strings.lua module now contains only a few useful utility functions; these could be moved to a stand-alone telescope.strings. (Except for dedent; that should be replaced.)
  • the border.lua and popup.lua can probably stay, but should be refactored to be a single UI utility module -- possibly moved into the telescope module. (That requires a bit more knowledge about the architecture than I have.) In any case, we don't need a wrapper that is expressly designed to make Nvim floating windows look like Vim popups (just something that makes our life easier).
  • the job.lua module should be replaced by vim.system; again, the deep integration makes this trickier but there should not be much feature disparity that would block this. One could start with refactoring the top utils.lua module and see where to go from there.
  • the async.lua (including vararg.lua, which is only used there) and log.lua are probably the biggest modules; these will have to stay for a bit until vim.async and vim.log are done, in which case migrating to those will be a rather big (but necessary) refactor.

So the plan for this PR is:

  1. Remove all usage of class, path, and scandir.
  2. Clean up border/popup, job, log, async and expose them for extensions.

A follow-up PR should rewrite job as a thin wrapper over vim.system and deprecate it (log and async will get the same treatment once the corresponding upstream modules are stable).

A couple of notes:

  • I am using this branch myself but can only test the features I use myself; it's quite likely I inadvertently broke some feature I don't use (and that isn't covered by tests). So I would appreciate outside testing -- you can just specify the feat/neoplen branch in your plugin spec.
  • The plenary.busted and test_harness modules are no longer in-tree but moved to an external plentest.nvim module that is a test-only dependency.
  • I have renamed the modules to neoplen exactly so they won't conflict with plenary installed as a dependency for an extension, but they of course will need to adapt in some way if we want to completely remove the dependency. I expect that this will involve a mix of using upstream API (for things like path) combined with simply pulling in one of the remaining neoplen modules. This is a bit tricky since I cleaned out modules that are still here, so I have probably removed functions that extensions rely on -- these will have to be added back. @delphinus
  • No more FFI.

@clason clason changed the title Feat/neoplen feat: vendor and clean up plenary Apr 10, 2026
@clason clason linked an issue Apr 10, 2026 that may be closed by this pull request
@clason clason force-pushed the feat/neoplen branch 3 times, most recently from d288d00 to 81463b9 Compare April 10, 2026 17:17
@clason clason requested review from Conni2461 and jamestrew April 10, 2026 17:19
@jamestrew

Copy link
Copy Markdown
Contributor

Not sure how to deal with docgen

I did make an effort to switch out the custom tree-sitter-lua based docgen for one based off of neovim core several years back. #3227

I can revive this.

@clason clason force-pushed the feat/neoplen branch 6 times, most recently from 2ca4b60 to bd0c1ae Compare April 10, 2026 17:45
@delphinus

Copy link
Copy Markdown
Member

Thank you @clason . I almost understood and agreed the changes. I will use this branch and check extensions' behaviors.

@clason clason force-pushed the feat/neoplen branch 2 times, most recently from ef0c587 to 9f14788 Compare April 13, 2026 16:06
@clason clason force-pushed the feat/neoplen branch 12 times, most recently from ad9b358 to 2c4fbe5 Compare April 19, 2026 15:12
clason and others added 18 commits May 23, 2026 15:34
Breaking change: drop directory preview from file previewer. This was
only used by `telescope-file-browser`, which is not actively maintained
and arguably out of scope.
Per #3647 (comment): bring back `neoplen.async.uv` with only the wrappers
extensions actually depend on.

Surveyed against telescope-frecency (draft PR
nvim-telescope/telescope-frecency.nvim#343), which uses these 7:
fs_stat, fs_open, fs_close, fs_read, fs_write, fs_unlink, fs_realpath.

`init.lua` gets a `uv = "neoplen.async.uv_async"` entry so call sites that
did `require("neoplen.async").uv.fs_*` keep working unchanged.

Adding more wrappers later is a single `add(name, argc)` call.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@clason

clason commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

@jamestrew If I understand this correctly, strings.dedent is only used for docgen -- in that case, can we move this (in a simplified, less general form) into your docgen module that is used now?

@jamestrew

Copy link
Copy Markdown
Contributor

@jamestrew If I understand this correctly, strings.dedent is only used for docgen -- in that case, can we move this (in a simplified, less general form) into your docgen module that is used now?

removing the ---@eval and the strings.dedent dependency here #3670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove plenary dependency

3 participants