Skip to content

Commit 9dabfb7

Browse files
committed
feat: add type annotations for plenary.reload
1 parent 9891f98 commit 9dabfb7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lua/plenary/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
---@field nvim_meta PlenaryNvimMeta
1515
---@field operators PlenaryOperators
1616
---@field path PlenaryPath
17+
---@field reload PlenaryReload
1718
---@field scandir PlenaryScandir
1819
---@field strings PlenaryStrings
1920
---@field tbl PlenaryTbl

lua/plenary/reload.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
---@class PlenaryReload
12
local reload = {}
23

4+
---@param module_name string
5+
---@param starts_with_only? boolean
36
reload.reload_module = function(module_name, starts_with_only)
47
-- Default to starts with only
58
if starts_with_only == nil then
@@ -9,17 +12,22 @@ reload.reload_module = function(module_name, starts_with_only)
912
-- TODO: Might need to handle cpath / compiled lua packages? Not sure.
1013
local matcher
1114
if not starts_with_only then
15+
---@param pack string
16+
---@return integer?
1217
matcher = function(pack)
1318
return string.find(pack, module_name, 1, true)
1419
end
1520
else
1621
local module_name_pattern = vim.pesc(module_name)
22+
---@param pack string
23+
---@return integer?
1724
matcher = function(pack)
1825
return string.find(pack, "^" .. module_name_pattern)
1926
end
2027
end
2128

2229
-- Handle impatient.nvim automatically.
30+
---@diagnostic disable-next-line: undefined-field
2331
local luacache = (_G.__luacache or {}).cache
2432

2533
for pack, _ in pairs(package.loaded) do

0 commit comments

Comments
 (0)