1
0
mirror of https://github.com/jiriks74/presence.nvim synced 2024-11-23 20:37:50 +01:00

Generalize file tree option to file explorers

This commit is contained in:
Andrew Kwon 2021-05-19 23:23:15 -07:00
parent d90ca22b3b
commit 70a3c23ae0
3 changed files with 14 additions and 12 deletions

@ -41,7 +41,7 @@ require("presence"):setup({
-- Rich Presence text options -- Rich Presence text options
editing_text = "Editing %s", -- Format string rendered when an editable file is loaded in the buffer 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 git_commit_text = "Committing changes" -- Format string rendered when commiting changes in git
plugin_manager_text = "Managing plugins" -- Format string rendered when managing plugins 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 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 " Rich Presence text options
let g:presence_editing_text = "Editing %s" 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_git_commit_text = "Committing changes"
let g:presence_plugin_manager_text = "Managing plugins" let g:presence_plugin_manager_text = "Managing plugins"
let g:presence_reading_text = "Reading %s" let g:presence_reading_text = "Reading %s"

@ -1,6 +1,7 @@
-- Different neovim file tree names -- Different neovim file explorer names keyed by filetype or buffer name
return { return {
["NvimTree"] = "NvimTree", ["NvimTree"] = "NvimTree",
["NERD_tree_"] = "NERDTree", ["NERD_tree_"] = "NERDTree",
["[defx] default-"] = "Defx", ["[defx] default-"] = "Defx",
["netrw"] = "Netrw",
} }

@ -71,7 +71,7 @@ local msgpack = require("deps.msgpack")
local serpent = require("deps.serpent") local serpent = require("deps.serpent")
local Discord = require("presence.discord") local Discord = require("presence.discord")
local file_assets = require("presence.file_assets") 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") local plugin_managers = require("presence.plugin_managers")
function Presence:setup(options) function Presence:setup(options)
@ -96,7 +96,7 @@ function Presence:setup(options)
self:set_option("neovim_image_text", "The One True Text Editor") self:set_option("neovim_image_text", "The One True Text Editor")
-- Status text options -- Status text options
self:set_option("editing_text", "Editing %s") 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("git_commit_text", "Committing changes")
self:set_option("plugin_manager_text", "Managing plugins") self:set_option("plugin_manager_text", "Managing plugins")
self:set_option("reading_text", "Reading %s") 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) return string.format(self.options.editing_text, filename)
end end
else else
local file_tree = file_trees[filename:match "[^%d]+"] local file_explorer = file_explorers[vim.bo.filetype:match "[^%d]+"]
if file_tree then or file_explorers[filename:match "[^%d]+"]
return string.format(self.options.file_tree_text, file_tree) local plugin_manager = plugin_managers[vim.bo.filetype]
elseif vim.bo.filetype == "netrw" then
return string.format(self.options.file_tree_text, "Netrw") if file_explorer then
elseif plugin_managers[vim.bo.filetype] then return string.format(self.options.file_explorer_text, file_explorer)
return string.format(self.options.plugin_manager_text, filename) elseif plugin_manager then
return string.format(self.options.plugin_manager_text, plugin_manager)
else else
return string.format(self.options.reading_text, filename) return string.format(self.options.reading_text, filename)
end end