feat: remove plenary.nvim dependency#54
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the plenary.nvim dependency by replacing its async/path utilities with Neovim-native APIs and a new internal neopyter.async module.
Changes:
- Dropped
plenary.nvimfrom install/repro scripts and docs, and replacedplenary.asyncusage withrequire("neopyter.async"). - Reworked filesystem/path handling to use
vim.fs,vim.uv, and string paths instead ofplenary.path. - Updated doc generation to include/expose the new async API and adjusted the Neovim gen-doc source branch.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/minimal_init.lua | Removes plenary from bootstrap dependencies (but still contains plenary runtime/test calls). |
| scripts/gen_doc.lua | Removes plenary from doc-gen dependencies; adds async docs + updates Neovim gen-doc source files/branch. |
| plugin/neopyter.lua | Switches async dependency from plenary.async to neopyter.async. |
| lua/neopyter/utils.lua | Replaces plenary.path usage with string paths + vim.fs/vim.uv. |
| lua/neopyter/treesitter.lua | Replaces plenary.path operations with vim.fs + vim.uv file ops. |
| lua/neopyter/rpc/proxy.lua | Switches async + libuv usage to neopyter.async and vim.uv. |
| lua/neopyter/rpc/direct.lua | Switches async dependency to neopyter.async. |
| lua/neopyter/jupyter/notebook.lua | Adds async annotations/documentation for async APIs. |
| lua/neopyter/jupyter/jupyterlab.lua | Removes plenary.path usage; adds execute_cmd and updates path/version reading. |
| lua/neopyter/health.lua | Updates run_blocking error handling callback shape. |
| lua/neopyter/async.lua | New native async wrapper built on vim._async + async wrappers for vim.fn/vim.api/vim.uv. |
| lua/neopyter.lua | Switches Windows detection/autocmd wiring to vim.uv + neopyter.async. |
| lua-tests/manual/repro-cmp.lua | Removes plenary from manual repro dependencies. |
| example/repro.lua | Removes plenary from example lazy repro dependencies. |
| README.md | Updates requirements/dependencies documentation to reflect removal of plenary. |
|
|
||
| if vim.startswith(fun.name, "async") then | ||
| fun.name = vim.split(fun.name, "%.")[2] | ||
| fun.module = "lua.neopyter.jupyter.async.lua" |
There was a problem hiding this comment.
In the doc generator transform, async functions are being reassigned to module lua.neopyter.jupyter.async.lua, but the file being documented is lua/neopyter/async.lua (not under jupyter/). This will generate incorrect module names/helptags; use the correct module path for async.
| fun.module = "lua.neopyter.jupyter.async.lua" | |
| fun.module = "lua.neopyter.async.lua" |
| @@ -157,7 +157,7 @@ Ultimately, `Neopyter` can control `Juppyter lab`. `Neopyter` can implement abil | |||
|
|
|||
| - 📔JupyterLab >= 4.0.0 | |||
| - ✌️ Neovim latest stable version or nightly version | |||
There was a problem hiding this comment.
The PR switches the runtime async implementation away from plenary and relies on newer built-in Neovim primitives (e.g. vim._async, vim.uv, vim.pack in scripts). The README currently says “latest stable or nightly” but doesn’t state a minimum Neovim version required for these APIs; please document the minimum supported Neovim version so users know what they need.
| - ✌️ Neovim latest stable version or nightly version | |
| - ✌️ Neovim >= 0.11.0 (latest stable or nightly recommended) |
| -- 'fs_lchown', | ||
| add("fs_copyfile", 4) | ||
| add("fs_opendir", 3, function(path, entries, callback) | ||
| return uv.fs_opendir(path, callback, entries) |
There was a problem hiding this comment.
fs_opendir wrapper uses an undefined uv identifier, so this module will error on load. Use vim.uv (or a local uv = vim.uv) and keep the argument order consistent with vim.uv.fs_opendir’s signature.
| return uv.fs_opendir(path, callback, entries) | |
| return vim.uv.fs_opendir(path, entries, callback) |
| return async.run(function() | ||
| return value(unpack(params)) | ||
| end, function(result) | ||
| local utils = require("neopyter.utils") | ||
| ---WARN:Only when the user directly calls the API from the main thread, e.g. autocmd, keymap, |
There was a problem hiding this comment.
async.run invokes callbacks as (err, ...), but the callback passed here is function(result) so result will actually receive the error value and successful return values will be shifted/dropped. Update the callback signature to accept (err, result) (and handle err) so notifications/logging reflect the real result.
|
|
||
| add_dependence("https://github.com/nvim-lua/plenary.nvim", "plenary.nvim") | ||
| add_dependence("https://github.com/nvim-treesitter/nvim-treesitter", "nvim-treesitter", "--branch", "main") | ||
| add_dependence("https://github.com/nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter-textobjects", "--branch", "main") |
There was a problem hiding this comment.
plenary.nvim is no longer cloned/added to the runtimepath here, but later in this same script you still execute runtime plugin/plenary.vim and require("plenary.busted"). That will make the minimal init fail unless you either keep installing plenary for tests or replace/remove those plenary-specific test hooks.
| add_dependence("https://github.com/nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter-textobjects", "--branch", "main") | |
| add_dependence("https://github.com/nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter-textobjects", "--branch", "main") | |
| add_dependence("https://github.com/nvim-lua/plenary.nvim", "plenary.nvim") |
| local a = require("vim._async") | ||
|
|
||
|
|
||
|
|
||
| --- @brief Neopyter's async module, which provides async functions and utilities for Neopyter. | ||
| --- Which is built on top of native async support (`vim._async`) in Neovim, and provides a more convenient API for users to use async functions in Neopyter. | ||
| --- The API of neopyter are mostly async, and users could call them in a sync context, neopyter will automatically wrap them in an async context, so | ||
| --- that users could call them directly without worrying about async context, but the order of execution is not guaranteed, if you want to guarantee | ||
| --- the order of execution, you should use `require("neopyter.async").run(...)` to run them in an async context. |
There was a problem hiding this comment.
require("vim._async") depends on Neovim’s internal (underscore-prefixed) API and may not be available/stable across versions. Consider guarding this with pcall and providing a clear error (or fallback implementation) so users on unsupported Neovim versions get an actionable message.
| ---@param suspend_fn fun() | ||
| ---@param on_finish? fun(err: string?, ...:any) | ||
| ---@param timeout number? | ||
| function async.run_blocking(suspend_fn, on_finish, timeout) |
There was a problem hiding this comment.
async.run_blocking documents on_finish as optional, but the implementation unconditionally calls it, which will error if it’s omitted. Either make on_finish required (update annotations) or provide a default callback like async.run does.
| function async.run_blocking(suspend_fn, on_finish, timeout) | |
| function async.run_blocking(suspend_fn, on_finish, timeout) | |
| if on_finish == nil then | |
| on_finish = function(err) | |
| if err then | |
| error(err) | |
| end | |
| end | |
| end |
| -- add('read_start', 2) -- do not do this one, the callback is made multiple times | ||
| add("write", 3) | ||
| add("write2", 4) | ||
| add("shutdown", 2) |
There was a problem hiding this comment.
add("shutdown", 2) is listed twice in the stream section, which is redundant and makes the wrapper list harder to maintain. Remove the duplicate entry (or replace it with the intended missing wrapper if this was a copy/paste).
| add("shutdown", 2) |
| local Path = require("plenary.path") | ||
| local utils = require("neopyter.utils") | ||
| local a = require("neopyter.async") | ||
| local uv = a.uv |
There was a problem hiding this comment.
local uv = a.uv is declared but never used in this module (you call vim.uv.* directly below). Remove the unused local or consistently use uv to avoid lint noise/confusion.
| local uv = a.uv |
d9d86db to
0131332
Compare
0131332 to
2afd6c7
Compare
Remove
plenary.nvimdependency, fix #51vim._asyncto replaceplenary.asyncvim.fs.*andvim.uv.*to replaceplenary.path