diff --git a/README.md b/README.md index ac831e1..a8563de 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ require("presence"):setup({ -- Rich Presence text options editing_text = "Editing %s", -- Format string rendered when an editable file is loaded in the buffer - file_tree_text = "Browsing %s" -- Format string rendered when browsing a file tree + file_explorer_text = "Browsing %s" -- Format string rendered when browsing a file explorer git_commit_text = "Committing changes" -- Format string rendered when commiting changes in git plugin_manager_text = "Managing plugins" -- Format string rendered when managing plugins reading_text = "Reading %s" -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer @@ -62,7 +62,7 @@ let g:presence_debounce_timeout = 15 " Rich Presence text options let g:presence_editing_text = "Editing %s" -let g:presence_file_tree_text = "Browsing %s" +let g:presence_file_explorer_text = "Browsing %s" let g:presence_git_commit_text = "Committing changes" let g:presence_plugin_manager_text = "Managing plugins" let g:presence_reading_text = "Reading %s" diff --git a/lua/presence/file_trees.lua b/lua/presence/file_explorers.lua similarity index 52% rename from lua/presence/file_trees.lua rename to lua/presence/file_explorers.lua index e520207..f1d4eaf 100644 --- a/lua/presence/file_trees.lua +++ b/lua/presence/file_explorers.lua @@ -1,6 +1,7 @@ --- Different neovim file tree names +-- Different neovim file explorer names keyed by filetype or buffer name return { ["NvimTree"] = "NvimTree", ["NERD_tree_"] = "NERDTree", ["[defx] default-"] = "Defx", + ["netrw"] = "Netrw", } diff --git a/lua/presence/init.lua b/lua/presence/init.lua index 2dff2ff..32260da 100644 --- a/lua/presence/init.lua +++ b/lua/presence/init.lua @@ -71,7 +71,7 @@ local msgpack = require("deps.msgpack") local serpent = require("deps.serpent") local Discord = require("presence.discord") local file_assets = require("presence.file_assets") -local file_trees = require("presence.file_trees") +local file_explorers = require("presence.file_explorers") local plugin_managers = require("presence.plugin_managers") function Presence:setup(options) @@ -96,7 +96,7 @@ function Presence:setup(options) self:set_option("neovim_image_text", "The One True Text Editor") -- Status text options self:set_option("editing_text", "Editing %s") - self:set_option("file_tree_text", "Browsing %s") + self:set_option("file_explorer_text", "Browsing %s") self:set_option("git_commit_text", "Committing changes") self:set_option("plugin_manager_text", "Managing plugins") self:set_option("reading_text", "Reading %s") @@ -361,13 +361,14 @@ function Presence:get_status_text(filename) return string.format(self.options.editing_text, filename) end else - local file_tree = file_trees[filename:match "[^%d]+"] - if file_tree then - return string.format(self.options.file_tree_text, file_tree) - elseif vim.bo.filetype == "netrw" then - return string.format(self.options.file_tree_text, "Netrw") - elseif plugin_managers[vim.bo.filetype] then - return string.format(self.options.plugin_manager_text, filename) + local file_explorer = file_explorers[vim.bo.filetype:match "[^%d]+"] + or file_explorers[filename:match "[^%d]+"] + local plugin_manager = plugin_managers[vim.bo.filetype] + + if file_explorer then + return string.format(self.options.file_explorer_text, file_explorer) + elseif plugin_manager then + return string.format(self.options.plugin_manager_text, plugin_manager) else return string.format(self.options.reading_text, filename) end