telescope-frecency.nvim/lua/frecency/web_devicons.lua
JINNOUCHI Yasushi 1f32091e2b
refactor!: use OO & add tests (#100)
* I did an overhall for all codes and added typing by Lua-language-server and tests. It also works on CI.
* Now it searches files on the workspace completely asynchronously. It does not block your text input. (Fix #106)
Make count = 1 when you open a file you've never opened (Fix #107)
2023-08-06 16:02:37 +09:00

29 lines
773 B
Lua

---@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 = {}
---@param enable boolean
---@return WebDevicons
WebDevicons.new = function(enable)
local ok, web_devicons = pcall(require, "nvim-web-devicons")
return setmetatable({ is_enabled = enable 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