From ff3fedb007a4b70f7c797cbcdccde053a14e2c23 Mon Sep 17 00:00:00 2001 From: Donatas Date: Mon, 8 Jul 2024 07:24:12 +0300 Subject: [PATCH] `branch` supports `oil` now (#1242) * lualine filename oil * git branch oil support * revert * sure fire way to get current dir --- lua/lualine/components/branch/git_branch.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index dcc9775ff..0daaab63a 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -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'))