Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch supports oil now #1242

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/lualine/components/branch/git_branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ 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
local ok, dir = pcall(oil.get_current_dir)
if ok and dir and dir ~= '' then
file_dir = vim.fn.fnamemodify(dir, ":p:h")
end
end

-- extract correct file dir from terminals
if file_dir and file_dir:match('term://.*') then
file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', '%1'))
Expand Down
Loading