Skip to content

Commit

Permalink
fix: Use package.loaded instead of require to check if oil exists (#1275
Browse files Browse the repository at this point in the history
)
  • Loading branch information
polirritmico authored Jul 15, 2024
1 parent baa7267 commit 544dd15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/lualine/components/branch/git_branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function M.find_git_dir(dir_path)
-- get file dir so we can search from that dir
local file_dir = dir_path or vim.fn.expand('%:p:h')

local oil_exists, oil = pcall(require, 'oil')
if oil_exists then
if package.loaded.oil then
local oil = require('oil')
local ok, dir = pcall(oil.get_current_dir)
if ok and dir and dir ~= '' then
file_dir = vim.fn.fnamemodify(dir, ':p:h')
Expand Down

0 comments on commit 544dd15

Please sign in to comment.