Skip to content

Commit

Permalink
feat: Support oil.nvim file explore (#58)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nick22985 authored Aug 11, 2024
1 parent 2f77b19 commit 25076ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/presence/file_explorers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ return {
["TelescopePrompt"] = "Telescope",
["neo-tree"] = "Neotree",
["fern"] = "Fern",
["oil"] = "Oil",
}
9 changes: 8 additions & 1 deletion lua/presence/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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([["]], [[\"]])

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25076ce

Please sign in to comment.