Skip to content

Commit 9b5896b

Browse files
committed
fix: correctly check if mini.icons is actually setup
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.
1 parent a543ea5 commit 9b5896b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

lua/oil/util.lua

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ M.add_title_to_win = function(winid, opts)
431431
end
432432
local new_title = get_title()
433433
local new_width =
434-
math.min(vim.api.nvim_win_get_width(winid) - 4, 2 + vim.api.nvim_strwidth(new_title))
434+
math.min(vim.api.nvim_win_get_width(winid) - 4, 2 + vim.api.nvim_strwidth(new_title))
435435
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, { " " .. new_title .. " " })
436436
vim.bo[bufnr].modified = false
437437
vim.api.nvim_win_set_width(title_winid, new_width)
@@ -486,13 +486,13 @@ M.get_adapter_for_action = function(action)
486486
local dest_adapter = assert(config.get_adapter_by_scheme(action.dest_url))
487487
if adapter ~= dest_adapter then
488488
if
489-
adapter.supported_cross_adapter_actions
490-
and adapter.supported_cross_adapter_actions[dest_adapter.name]
489+
adapter.supported_cross_adapter_actions
490+
and adapter.supported_cross_adapter_actions[dest_adapter.name]
491491
then
492492
return adapter, adapter.supported_cross_adapter_actions[dest_adapter.name]
493493
elseif
494-
dest_adapter.supported_cross_adapter_actions
495-
and dest_adapter.supported_cross_adapter_actions[adapter.name]
494+
dest_adapter.supported_cross_adapter_actions
495+
and dest_adapter.supported_cross_adapter_actions[adapter.name]
496496
then
497497
return dest_adapter, dest_adapter.supported_cross_adapter_actions[adapter.name]
498498
else
@@ -686,9 +686,9 @@ end
686686
---@return nil|integer
687687
M.buf_get_win = function(bufnr, preferred_win)
688688
if
689-
preferred_win
690-
and vim.api.nvim_win_is_valid(preferred_win)
691-
and vim.api.nvim_win_get_buf(preferred_win) == bufnr
689+
preferred_win
690+
and vim.api.nvim_win_is_valid(preferred_win)
691+
and vim.api.nvim_win_get_buf(preferred_win) == bufnr
692692
then
693693
return preferred_win
694694
end
@@ -825,12 +825,12 @@ end
825825
---@return boolean
826826
M.is_directory = function(entry)
827827
local is_directory = entry.type == "directory"
828-
or (
829-
entry.type == "link"
830-
and entry.meta
831-
and entry.meta.link_stat
832-
and entry.meta.link_stat.type == "directory"
833-
)
828+
or (
829+
entry.type == "link"
830+
and entry.meta
831+
and entry.meta.link_stat
832+
and entry.meta.link_stat.type == "directory"
833+
)
834834
return is_directory == true
835835
end
836836

@@ -865,7 +865,8 @@ end
865865
M.get_icon_provider = function()
866866
-- prefer mini.icons
867867
local has_mini_icons, mini_icons = pcall(require, "mini.icons")
868-
if has_mini_icons then
868+
---@diagnostic disable-next-line: undefined-field
869+
if has_mini_icons and _G.MiniIcons then
869870
return function(type, name)
870871
return mini_icons.get(type == "directory" and "directory" or "file", name)
871872
end

0 commit comments

Comments
 (0)