Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"cast-type-mismatch",
"missing-fields"
],
"workspace.checkThirdParty": false
}
"workspace.checkThirdParty": false,
"workspace.library": [
"$VIMRUNTIME",
]
}
6 changes: 3 additions & 3 deletions lua/diffview/hl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ if HAS_NVIM_0_8 then
}
end

vim.tbl_add_reverse_lookup(M.HlAttribute)
vim.tbl_add_reverse_lookup(style_attrs)
utils.add_reverse_lookup(M.HlAttribute)
utils.add_reverse_lookup(style_attrs)
local hlattr = M.HlAttribute

---@param name string Syntax group name.
Expand Down Expand Up @@ -242,7 +242,7 @@ function M.hi_spec_to_def_map(spec)
end

if spec.style then
local spec_attrs = vim.tbl_add_reverse_lookup(vim.split(spec.style, ","))
local spec_attrs = utils.add_reverse_lookup(vim.split(spec.style, ","))

for _, attr in ipairs(style_attrs) do
res[attr] = spec_attrs[attr] ~= nil
Expand Down
2 changes: 1 addition & 1 deletion lua/diffview/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ end
---@return boolean
function M.is_buf_in_use(bufnr, ignore)
local ignore_map = ignore and utils.vec_slice(ignore) or {}
vim.tbl_add_reverse_lookup(ignore_map)
utils.add_reverse_lookup(ignore_map)

for _, view in ipairs(M.views) do
if view:instanceof(StandardView.__get()) then
Expand Down
5 changes: 4 additions & 1 deletion lua/diffview/oop.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local lazy = require("diffview.lazy")
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"

local fmt = string.format

local M = {}
Expand All @@ -10,7 +13,7 @@ end
---@param t T
---@return T
function M.enum(t)
vim.tbl_add_reverse_lookup(t)
utils.add_reverse_lookup(t)
return t
end

Expand Down
7 changes: 7 additions & 0 deletions lua/diffview/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1346,4 +1346,11 @@ end

M.path_sep = path_sep

--- @param t table
--- @return table t
function M.add_reverse_lookup(t)
for k, v in pairs(t) do t[v] = k end
return t
end

return M