Skip to content

Commit 4005c96

Browse files
authored
fix: handle deprecated util 'tbl_add_reverse_lookup()' (#492)
1 parent 3dc498c commit 4005c96

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

.luarc.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
"cast-type-mismatch",
66
"missing-fields"
77
],
8-
"workspace.checkThirdParty": false
9-
}
8+
"workspace.checkThirdParty": false,
9+
"workspace.library": [
10+
"$VIMRUNTIME",
11+
]
12+
}

lua/diffview/hl.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ if HAS_NVIM_0_8 then
114114
}
115115
end
116116

117-
vim.tbl_add_reverse_lookup(M.HlAttribute)
118-
vim.tbl_add_reverse_lookup(style_attrs)
117+
utils.add_reverse_lookup(M.HlAttribute)
118+
utils.add_reverse_lookup(style_attrs)
119119
local hlattr = M.HlAttribute
120120

121121
---@param name string Syntax group name.
@@ -242,7 +242,7 @@ function M.hi_spec_to_def_map(spec)
242242
end
243243

244244
if spec.style then
245-
local spec_attrs = vim.tbl_add_reverse_lookup(vim.split(spec.style, ","))
245+
local spec_attrs = utils.add_reverse_lookup(vim.split(spec.style, ","))
246246

247247
for _, attr in ipairs(style_attrs) do
248248
res[attr] = spec_attrs[attr] ~= nil

lua/diffview/lib.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ end
199199
---@return boolean
200200
function M.is_buf_in_use(bufnr, ignore)
201201
local ignore_map = ignore and utils.vec_slice(ignore) or {}
202-
vim.tbl_add_reverse_lookup(ignore_map)
202+
utils.add_reverse_lookup(ignore_map)
203203

204204
for _, view in ipairs(M.views) do
205205
if view:instanceof(StandardView.__get()) then

lua/diffview/oop.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
local lazy = require("diffview.lazy")
2+
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
3+
14
local fmt = string.format
25

36
local M = {}
@@ -10,7 +13,7 @@ end
1013
---@param t T
1114
---@return T
1215
function M.enum(t)
13-
vim.tbl_add_reverse_lookup(t)
16+
utils.add_reverse_lookup(t)
1417
return t
1518
end
1619

lua/diffview/utils.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,4 +1346,11 @@ end
13461346

13471347
M.path_sep = path_sep
13481348

1349+
--- @param t table
1350+
--- @return table t
1351+
function M.add_reverse_lookup(t)
1352+
for k, v in pairs(t) do t[v] = k end
1353+
return t
1354+
end
1355+
13491356
return M

0 commit comments

Comments
 (0)