Skip to content

feat: remove plenary.nvim dependency#54

Merged
AbaoFromCUG merged 1 commit intomasterfrom
abao/remove_plenary
Apr 20, 2026
Merged

feat: remove plenary.nvim dependency#54
AbaoFromCUG merged 1 commit intomasterfrom
abao/remove_plenary

Conversation

@AbaoFromCUG
Copy link
Copy Markdown
Collaborator

@AbaoFromCUG AbaoFromCUG commented Apr 20, 2026

Remove plenary.nvim dependency, fix #51

  • Use vim._async to replace plenary.async
  • Use vim.fs.* and vim.uv.* to replace plenary.path

Copilot AI review requested due to automatic review settings April 20, 2026 13:47
@AbaoFromCUG AbaoFromCUG added the enhancement New feature or request label Apr 20, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.nvim from install/repro scripts and docs, and replaced plenary.async usage with require("neopyter.async").
  • Reworked filesystem/path handling to use vim.fs, vim.uv, and string paths instead of plenary.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.

Comment thread scripts/gen_doc.lua

if vim.startswith(fun.name, "async") then
fun.name = vim.split(fun.name, "%.")[2]
fun.module = "lua.neopyter.jupyter.async.lua"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
fun.module = "lua.neopyter.jupyter.async.lua"
fun.module = "lua.neopyter.async.lua"

Copilot uses AI. Check for mistakes.
Comment thread README.md
@@ -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
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- ✌️ Neovim latest stable version or nightly version
- ✌️ Neovim >= 0.11.0 (latest stable or nightly recommended)

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/async.lua
-- 'fs_lchown',
add("fs_copyfile", 4)
add("fs_opendir", 3, function(path, entries, callback)
return uv.fs_opendir(path, callback, entries)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return uv.fs_opendir(path, callback, entries)
return vim.uv.fs_opendir(path, entries, callback)

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/async.lua
Comment on lines +276 to 280
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,
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread scripts/minimal_init.lua

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")
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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")

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/async.lua
Comment on lines +1 to +9
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.
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/async.lua
---@param suspend_fn fun()
---@param on_finish? fun(err: string?, ...:any)
---@param timeout number?
function async.run_blocking(suspend_fn, on_finish, timeout)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/async.lua
-- add('read_start', 2) -- do not do this one, the callback is made multiple times
add("write", 3)
add("write2", 4)
add("shutdown", 2)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
add("shutdown", 2)

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/treesitter.lua Outdated
local Path = require("plenary.path")
local utils = require("neopyter.utils")
local a = require("neopyter.async")
local uv = a.uv
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
local uv = a.uv

Copilot uses AI. Check for mistakes.
@AbaoFromCUG AbaoFromCUG force-pushed the abao/remove_plenary branch 2 times, most recently from d9d86db to 0131332 Compare April 20, 2026 15:44
@AbaoFromCUG AbaoFromCUG force-pushed the abao/remove_plenary branch from 0131332 to 2afd6c7 Compare April 20, 2026 16:06
@AbaoFromCUG AbaoFromCUG merged commit eb2e1bf into master Apr 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plenary is about to be archived

2 participants