Skip to content

Commit 78d40e5

Browse files
committed
ux: add deprecation warning for old functions
1 parent 798216b commit 78d40e5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lua/archwiki/api.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- used to warn users at commit f770bfbdb3b60f7c0dc73b1685e476aabe98e773 or earlier
2+
-- that their have been breaking changes
3+
4+
---@param fn_name string
5+
---@param replacements string[]
6+
local function warn_no_longer_exists(fn_name, replacements)
7+
assert(#replacements ~= 0)
8+
return function()
9+
vim.notify(
10+
"Function '" ..
11+
fn_name .. "' no longer exists. It was replaced by [" .. vim.fn.join(replacements, ', ') .. "]",
12+
vim.log.levels.ERROR)
13+
end
14+
end
15+
16+
local M = {}
17+
18+
M.select_page_from_local = warn_no_longer_exists("select_page_from_local", { "read_page", "local_search" })
19+
M.read_page_into_buffer = warn_no_longer_exists("read_page_into_buffer", { "read_page", "read_page_raw" })
20+
21+
return M

lua/archwiki/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ local min_version = "3.2.0"
1111
local max_version = nil
1212

1313
local function warn_no_setup()
14-
vim.notify("You have to call 'require(\"archwiki\").setup()' before you can run this function")
14+
vim.notify("You have to call 'require(\"archwiki\").setup()' before you can run this function", vim.log.levels.ERROR)
1515
end
1616

17-
1817
local M = {}
1918
M.config = Config
2019

@@ -24,6 +23,7 @@ M.text_search = warn_no_setup
2423
M.page_search = warn_no_setup
2524
M.local_search = warn_no_setup
2625

26+
2727
---@param cfg table
2828
function M.setup(cfg)
2929
Config = vim.tbl_deep_extend("force", Config, cfg or {})

0 commit comments

Comments
 (0)