Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/frecency/file_lock.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local log = require "frecency.log"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

---@class FrecencyFileLock
---@field base string
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/finder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local log = require "frecency.log"
local timer = require "frecency.timer"
local lazy_require = require "frecency.lazy_require"
local Sorter = require "frecency.sorter"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

---@class FrecencyFinder
---@field config FrecencyFinderConfig
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local config = require "frecency.config"
local os_util = require "frecency.os_util"
local log = require "frecency.log"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

---@class FrecencyFS
local M = {
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local frecency = setmetatable({}, {
})

local function async_call(f, ...)
require("plenary.async").void(f)(...)
require("neoplen.async").void(f)(...)
end

local setup_done = false
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/klass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local log = require "frecency.log"
local timer = require "frecency.timer"
local wait = require "frecency.wait"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

---@enum FrecencyStatus
local STATUS = {
Expand Down
13 changes: 13 additions & 0 deletions lua/frecency/lazy_require.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
-- Compat: neoplen.async dropped its `uv` submodule in telescope.nvim commit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's back now :) So this can be removed.

-- b9b203f ("feat(plenary): remove unused async") because telescope itself does
-- not use it. frecency relies on the async-aware libuv wrappers, so until
-- upstream restores them (asked for in nvim-telescope/telescope.nvim#3647),
-- re-attach plenary's uv_async to the neoplen.async module table. Runs once
-- per session as a side effect of loading this module.
do
local ok, async = pcall(require, "neoplen.async")
if ok and not async.uv then
async.uv = require "plenary.async.uv_async"
end
end

---@param module string
return function(module)
return setmetatable({}, {
Expand Down
15 changes: 14 additions & 1 deletion lua/frecency/log.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
local config = require "frecency.config"
local lazy_require = require "frecency.lazy_require"
local log = lazy_require "plenary.log"
local log = lazy_require "neoplen.log"

-- Compat: neoplen.log dropped plenary.log's "create the outfile parent dir if
-- missing" step when it stopped depending on plenary.path. The default outfile
-- is `stdpath("log")/neoplen.log`, and on a fresh XDG_STATE_HOME (e.g. CI
-- sandboxes or our test runner) that directory does not exist yet, so the
-- first log line throws ENOENT. Ensure the dir exists once at load time.
-- Track restoration upstream in nvim-telescope/telescope.nvim#3647.
do
local log_dir = vim.fn.stdpath "log" --[[@as string]]
if vim.fn.isdirectory(log_dir) == 0 then
vim.fn.mkdir(log_dir, "p")
end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also moved that back in neoplen.log


return setmetatable({}, {
__index = function(_, key)
Expand Down
4 changes: 2 additions & 2 deletions lua/frecency/tests/database_spec.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local Database = require "frecency.database"
local config = require "frecency.config"
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = require "neoplen.async" --[[@as FrecencyPlenaryAsync]]
local util = require "frecency.tests.util"
async.tests.add_to_env()
util.add_async_to_env()

local function with_database(f)
local dir, close = util.tmpdir()
Expand Down
4 changes: 2 additions & 2 deletions lua/frecency/tests/file_lock_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
local config = require "frecency.config"
local FileLock = require "frecency.file_lock"
local util = require "frecency.tests.util"
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
require("plenary.async").tests.add_to_env()
local async = require "neoplen.async" --[[@as FrecencyPlenaryAsync]]
util.add_async_to_env()

config.setup { debug = true }

Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/tests/frecency_validate_database_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local util = require "frecency.tests.util"
local async = require "plenary.async"
local async = require "neoplen.async"

local filepath = util.filepath
local make_epoch = util.make_epoch
Expand Down
30 changes: 28 additions & 2 deletions lua/frecency/tests/util.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---@diagnostic disable: invisible, undefined-field
-- luacheck: globals describe it pending before_each after_each
local Frecency = require "frecency.klass"
local Picker = require "frecency.picker"
local config = require "frecency.config"
local log = require "plenary.log"
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local log = require "neoplen.log"
local async = require "neoplen.async" --[[@as FrecencyPlenaryAsync]]
local Path = require "plenary.path"
local Job = require "plenary.job"
local wait = require "frecency.wait"
Expand Down Expand Up @@ -199,7 +200,32 @@ local function with_fake_vim_ui_select(choice, callback)
vim.ui.select = original_vim_ui_select
end

-- Replacement for `require("plenary.async").tests.add_to_env()` — neoplen
-- removed the `async.tests` submodule, so we inline the minimal helpers that
-- frecency's spec files use (`a.describe` / `a.it` / `a.before_each` /
-- `a.after_each` / `a.pending`). Sets `_G.a` so call sites resolve through the
-- global table the same way `setfenv`-based add_to_env did.
local function add_async_to_env()
local timeout = tonumber(vim.env.PLENARY_TEST_TIMEOUT)
_G.a = {
describe = describe,
it = function(s, async_func)
it(s, async.util.will_block(async_func, timeout))
end,
pending = function(async_func)
pending(async_func)
end,
before_each = function(async_func)
before_each(async.util.will_block(async_func))
end,
after_each = function(async_func)
after_each(async.util.will_block(async_func))
end,
}
end

return {
add_async_to_env = add_async_to_env,
filepath = filepath,
make_epoch = make_epoch,
make_register = make_register,
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/v2/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local os_util = require "frecency.os_util"
local timer = require "frecency.timer"
local watcher = require "frecency.watcher"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

-- todo(clason): remove when dropping support for Nvim 0.12
local npcall = vim.npcall or vim.F.npcall
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/v2/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local log = require "frecency.log"
local timer = require "frecency.timer"
local wait = require "frecency.wait"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

-- v1 record / data shape kept here because TableV2:from_v1 still consumes
-- them for the v1 → v2 migration in 2.0.0.
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/wait.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local async = require "plenary.async"
local async = require "neoplen.async"

---@class FrecencyWait
---@field config FrecencyWaitConfig
Expand Down
2 changes: 1 addition & 1 deletion lua/frecency/watcher.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local log = require "frecency.log"
local lazy_require = require "frecency.lazy_require"
local async = lazy_require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local async = lazy_require "neoplen.async" --[[@as FrecencyPlenaryAsync]]

---@class FrecencyWatcherMtime
---@field sec integer
Expand Down
Loading