Skip to content

Commit 544dd15

Browse files
authored
fix: Use package.loaded instead of require to check if oil exists (#1275)
1 parent baa7267 commit 544dd15

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lua/lualine/components/branch/git_branch.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ function M.find_git_dir(dir_path)
7777
-- get file dir so we can search from that dir
7878
local file_dir = dir_path or vim.fn.expand('%:p:h')
7979

80-
local oil_exists, oil = pcall(require, 'oil')
81-
if oil_exists then
80+
if package.loaded.oil then
81+
local oil = require('oil')
8282
local ok, dir = pcall(oil.get_current_dir)
8383
if ok and dir and dir ~= '' then
8484
file_dir = vim.fn.fnamemodify(dir, ':p:h')

0 commit comments

Comments
 (0)