From 05234a67baf2e5f4a19eed61da60aac852d24f48 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 2 Mar 2026 19:26:02 -0500 Subject: [PATCH] fix: use guard clause --- lua/oil/util.lua | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lua/oil/util.lua b/lua/oil/util.lua index 413e7eb..b04b6a9 100644 --- a/lua/oil/util.lua +++ b/lua/oil/util.lua @@ -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