telescope-frecency.nvim/lua/frecency/web_devicons.lua
JINNOUCHI Yasushi 2a22815b09
Simplify code with using frecency.config (#189)
* chore: change the position of `?`

* fix: use config module to simplify code

* test: fix tests to use frecency.config

* test: remove macOS with nightly Neovim temporarily
2024-03-25 18:45:45 +09:00

33 lines
817 B
Lua

local config = require "frecency.config"
---@class WebDeviconsModule
---@field get_icon fun(name?: string, ext?: string, opts?: table): string, string
---@class WebDevicons
---@field is_enabled boolean
---@field private web_devicons WebDeviconsModule
local WebDevicons = {}
---@return WebDevicons
WebDevicons.new = function()
local ok, web_devicons = pcall(require, "nvim-web-devicons")
return setmetatable(
{ is_enabled = not config.disable_devicons and ok, web_devicons = web_devicons },
{ __index = WebDevicons }
)
end
---@param name string?
---@param ext string?
---@param opts table?
---@return string
---@return string
function WebDevicons:get_icon(name, ext, opts)
if self.is_enabled then
return self.web_devicons.get_icon(name, ext, opts)
end
return "", ""
end
return WebDevicons