From 25076ce0921d68a1d998a66daccc68f9d5d7b087 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 11 Aug 2024 17:05:33 +1000 Subject: [PATCH] feat: Support oil.nvim file explore (#58) * feat: Support oil.nvim file explore * feat: more explicitly look for oil at the start of file_path * feat: oil working with git buttons work by @nick22985 --- lua/presence/file_explorers.lua | 1 + lua/presence/init.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/presence/file_explorers.lua b/lua/presence/file_explorers.lua index 5d33273..ed10c4f 100644 --- a/lua/presence/file_explorers.lua +++ b/lua/presence/file_explorers.lua @@ -7,4 +7,5 @@ return { ["TelescopePrompt"] = "Telescope", ["neo-tree"] = "Neotree", ["fern"] = "Fern", + ["oil"] = "Oil", } diff --git a/lua/presence/init.lua b/lua/presence/init.lua index 5b6f844..1238aec 100644 --- a/lua/presence/init.lua +++ b/lua/presence/init.lua @@ -439,7 +439,10 @@ function Presence:get_project_name(file_path) if not file_path then return nil end - + -- if filepath has oil:// remove it + if file_path:find("^oil://") then + file_path = file_path:gsub("oil://", "") + end -- Escape quotes in the file path file_path = file_path:gsub([["]], [[\"]]) @@ -763,6 +766,10 @@ end -- Get either user-configured buttons or the create default "View Repository" button definition function Presence:get_buttons(buffer, parent_dirpath) + if parent_dirpath ~= nil and parent_dirpath:find("^oil://") then + parent_dirpath = parent_dirpath:gsub("oil://", "") + end + -- User configured a static buttons table if type(self.options.buttons) == "table" then local is_plural = #self.options.buttons > 1