From 41d3ef7ff81b9a802d36837336bbb2e3cedd5df5 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Tue, 9 Apr 2024 15:08:56 +0200
Subject: [PATCH 1/3] prevent error messages when opening unnamed buffer

---
 lua/presence/init.lua | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/lua/presence/init.lua b/lua/presence/init.lua
index 1972fc5..a276003 100644
--- a/lua/presence/init.lua
+++ b/lua/presence/init.lua
@@ -800,11 +800,11 @@ function Presence:update_for_buffer(buffer, should_debounce)
 		return
 	end
 
-	-- Parse vim buffer
-	local filename = self.get_filename(buffer, self.os.path_separator)
-	local parent_dirpath = self.get_dir_path(buffer, self.os.path_separator)
-	local extension = filename and self.get_file_extension(filename) or nil
-	self.log:debug(string.format("Parsed filename %s with %s extension", filename, extension or "no"))
+  -- Parse vim buffer
+  local filename = self.get_filename(buffer, self.os.path_separator)
+  local parent_dirpath = self.get_dir_path(buffer, self.os.path_separator)
+  local extension = filename and self.get_file_extension(filename) or nil
+  self.log:debug(string.format("Parsed filename %s with %s extension", filename or "no", extension or "no"))
 
 	-- Return early if there is no valid activity status text to set
 	local status_text = self:get_status_text(filename)
@@ -812,9 +812,9 @@ function Presence:update_for_buffer(buffer, should_debounce)
 		return self.log:debug("No status text for the given buffer, skipping...")
 	end
 
-	-- Get project information
-	self.log:debug(string.format("Getting project name for %s...", parent_dirpath))
-	local project_name, project_path = self:get_project_name(parent_dirpath)
+  -- Get project information
+  self.log:debug(string.format("Getting project name for %s...", parent_dirpath or "no"))
+  local project_name, project_path = self:get_project_name(parent_dirpath)
 
 	-- Check for blacklist
 	local is_blacklisted = #self.options.blacklist > 0 and self:check_blacklist(buffer, parent_dirpath, project_path)
@@ -825,10 +825,11 @@ function Presence:update_for_buffer(buffer, should_debounce)
 		return
 	end
 
-	local activity_set_at = os.time()
-	-- If we shouldn't debounce and we trigger an activity, keep this value the same.
-	-- Otherwise set it to the current time.
-	local relative_activity_set_at = should_debounce and self.last_activity.relative_set_at or os.time()
+  local activity_set_at = os.time()
+  -- If we shouldn't debounce and we trigger an activity, keep this value the same.
+  -- Otherwise set it to the current time.
+  -- local relative_activity_set_at = should_debounce and self.last_activity.relative_set_at or os.time()
+  local relative_activity_set_at = self.last_activity.relative_set_at or os.time()
 
 	self.log:debug(string.format("Setting activity for %s...", buffer and #buffer > 0 and buffer or "unnamed buffer"))
 

From 9dcf608de4346b0765777f50c26d9dcabb4ac919 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Tue, 9 Apr 2024 15:15:29 +0200
Subject: [PATCH 2/3] fix: remove unused argument

---
 lua/presence/init.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lua/presence/init.lua b/lua/presence/init.lua
index a276003..29e2ed4 100644
--- a/lua/presence/init.lua
+++ b/lua/presence/init.lua
@@ -792,7 +792,7 @@ function Presence:get_buttons(buffer, parent_dirpath)
 end
 
 -- Update Rich Presence for the provided vim buffer
-function Presence:update_for_buffer(buffer, should_debounce)
+function Presence:update_for_buffer(buffer)
 	-- Avoid unnecessary updates if the previous activity was for the current buffer
 	-- (allow same-buffer updates when line numbers are enabled)
 	if self.options.enable_line_number == 0 and self.last_activity.file == buffer then

From 8a513b74d3dc8a40e534c7855af0c1d53b831aa5 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Tue, 9 Apr 2024 15:16:23 +0200
Subject: [PATCH 3/3] fix(formatting): format using stylua

---
 lua/presence/init.lua | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/lua/presence/init.lua b/lua/presence/init.lua
index 29e2ed4..351254a 100644
--- a/lua/presence/init.lua
+++ b/lua/presence/init.lua
@@ -800,11 +800,11 @@ function Presence:update_for_buffer(buffer)
 		return
 	end
 
-  -- Parse vim buffer
-  local filename = self.get_filename(buffer, self.os.path_separator)
-  local parent_dirpath = self.get_dir_path(buffer, self.os.path_separator)
-  local extension = filename and self.get_file_extension(filename) or nil
-  self.log:debug(string.format("Parsed filename %s with %s extension", filename or "no", extension or "no"))
+	-- Parse vim buffer
+	local filename = self.get_filename(buffer, self.os.path_separator)
+	local parent_dirpath = self.get_dir_path(buffer, self.os.path_separator)
+	local extension = filename and self.get_file_extension(filename) or nil
+	self.log:debug(string.format("Parsed filename %s with %s extension", filename or "no", extension or "no"))
 
 	-- Return early if there is no valid activity status text to set
 	local status_text = self:get_status_text(filename)
@@ -812,9 +812,9 @@ function Presence:update_for_buffer(buffer)
 		return self.log:debug("No status text for the given buffer, skipping...")
 	end
 
-  -- Get project information
-  self.log:debug(string.format("Getting project name for %s...", parent_dirpath or "no"))
-  local project_name, project_path = self:get_project_name(parent_dirpath)
+	-- Get project information
+	self.log:debug(string.format("Getting project name for %s...", parent_dirpath or "no"))
+	local project_name, project_path = self:get_project_name(parent_dirpath)
 
 	-- Check for blacklist
 	local is_blacklisted = #self.options.blacklist > 0 and self:check_blacklist(buffer, parent_dirpath, project_path)
@@ -825,11 +825,11 @@ function Presence:update_for_buffer(buffer)
 		return
 	end
 
-  local activity_set_at = os.time()
-  -- If we shouldn't debounce and we trigger an activity, keep this value the same.
-  -- Otherwise set it to the current time.
-  -- local relative_activity_set_at = should_debounce and self.last_activity.relative_set_at or os.time()
-  local relative_activity_set_at = self.last_activity.relative_set_at or os.time()
+	local activity_set_at = os.time()
+	-- If we shouldn't debounce and we trigger an activity, keep this value the same.
+	-- Otherwise set it to the current time.
+	-- local relative_activity_set_at = should_debounce and self.last_activity.relative_set_at or os.time()
+	local relative_activity_set_at = self.last_activity.relative_set_at or os.time()
 
 	self.log:debug(string.format("Setting activity for %s...", buffer and #buffer > 0 and buffer or "unnamed buffer"))