fix: use guard clause
This commit is contained in:
parent
262bf8710e
commit
05234a67ba
1 changed files with 17 additions and 14 deletions
|
|
@ -974,22 +974,25 @@ M.get_icon_provider = function()
|
|||
end
|
||||
|
||||
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
|
||||
if has_devicons then
|
||||
return function(type, name, conf, ft)
|
||||
if type == 'directory' then
|
||||
return conf and conf.directory or '', 'OilDirIcon'
|
||||
else
|
||||
if ft then
|
||||
local ft_icon, ft_hl = devicons.get_icon_by_filetype(ft)
|
||||
if ft_icon and ft_icon ~= '' then
|
||||
return ft_icon, ft_hl
|
||||
end
|
||||
|
||||
if not has_devicons then
|
||||
return
|
||||
end
|
||||
|
||||
return function(type, name, conf, ft)
|
||||
if type == 'directory' then
|
||||
return conf and conf.directory or '', 'OilDirIcon'
|
||||
else
|
||||
if ft then
|
||||
local ft_icon, ft_hl = devicons.get_icon_by_filetype(ft)
|
||||
if ft_icon and ft_icon ~= '' then
|
||||
return ft_icon, ft_hl
|
||||
end
|
||||
local icon, hl = devicons.get_icon(name)
|
||||
hl = hl or 'OilFileIcon'
|
||||
icon = icon or (conf and conf.default_file or '')
|
||||
return icon, hl
|
||||
end
|
||||
local icon, hl = devicons.get_icon(name)
|
||||
hl = hl or 'OilFileIcon'
|
||||
icon = icon or (conf and conf.default_file or '')
|
||||
return icon, hl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue