fix: correctly check if mini.icons is actually setup (#441)

This leaves the `pcall` just so (1) we load the plugin if it is lazy
loaded by the user and (2) we get LSP completion/validation with that
type as well.
This commit is contained in:
Micah Halter 2024-07-06 19:20:44 -04:00 committed by GitHub
parent a543ea598e
commit d5e56574f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -864,8 +864,9 @@ end
---@return (oil.IconProvider)?
M.get_icon_provider = function()
-- prefer mini.icons
local has_mini_icons, mini_icons = pcall(require, "mini.icons")
if has_mini_icons then
local _, mini_icons = pcall(require, "mini.icons")
---@diagnostic disable-next-line: undefined-field
if _G.MiniIcons then -- `_G.MiniIcons` is a better check to see if the module is setup
return function(type, name)
return mini_icons.get(type == "directory" and "directory" or "file", name)
end