Skip to content

Commit

Permalink
branch supports oil now (#1242)
Browse files Browse the repository at this point in the history
* lualine filename oil

* git branch oil support

* revert

* sure fire way to get current dir
  • Loading branch information
tronikelis authored Jul 8, 2024
1 parent e208967 commit ff3fedb
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit ff3fedb

Please sign in to comment.