dotfiles/home/apps/neovim/lua/plugins/presence.lua

123 lines
3.5 KiB
Lua
Raw Normal View History

---@type LazyPluginSpec[]
return {
{
"andweeb/presence.nvim",
config = function()
local presence = require("presence")
local function starts_with(self, str)
return self:find("^" .. str) ~= nil
end
local home = vim.fn.expand("$HOME") .. "/Code/"
local blacklist = {
[vim.fn.resolve(home .. "work")] = "Using nvim at work.",
[vim.fn.resolve(home .. "freelance")] = "Using nvim to freelance.",
}
---@param activity string?
---@param info string?
---@return {text: string, state: boolean}
local conceal = function(activity, info)
local cur_file = vim.fn.expand("%:p")
for k, v in pairs(blacklist) do
if starts_with(cur_file, k) then
return { text = v, state = true }
end
end
if info ~= nil then
return { text = activity .. " " .. info, state = false }
end
return { text = activity, state = false }
end
local v = vim.version()
local vStr = string.format("v%d.%d.%d", v.major, v.minor, v.patch)
presence:setup({
auto_update = true,
debounce_timeout = 10,
neovim_image_text = "Neovim " .. vStr,
-- Main image display (either "neovim" or "file")
main_image = "file",
2023-07-01 20:23:44 +02:00
show_time = true,
2023-08-21 07:05:47 +02:00
enable_line_number = true,
buttons = function(_, repo_url)
local concealed = conceal().state
if concealed then
return {
{
label = "View my config",
url = "https://github.com/nekowinston/dotfiles",
},
}
else
return {
{
label = "Steal the code",
url = repo_url,
},
}
end
end,
file_assets = {
2023-08-21 07:05:47 +02:00
["d"] = {
"Dlang",
"https://github.com/dlang.png",
},
2023-07-01 20:23:44 +02:00
["astro"] = {
"Astro",
"https://github.com/withastro.png",
},
["k8s.yaml"] = {
"Kubernetes",
2023-07-01 20:23:44 +02:00
"https://github.com/kubernetes.png",
},
["Chart.yaml"] = {
"Helm Chart",
"https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png",
},
["helmfile.yaml"] = {
"helmfile",
"https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png",
},
["prisma"] = {
"Prisma",
2023-07-01 20:23:44 +02:00
"https://github.com/prisma.png",
},
["bu"] = {
"Butane Config",
2023-07-01 20:23:44 +02:00
"https://github.com/coreos.png",
},
["ign"] = {
"CoreOS Ignition",
2023-07-01 20:23:44 +02:00
"https://github.com/coreos.png",
},
},
-- Rich Presence text options
editing_text = function(s)
return conceal("Editing", s).text
end,
reading_text = function(s)
return conceal("Reading", s).text
end,
file_explorer_text = function(s)
return conceal("Browsing", s).text
end,
workspace_text = function(s)
local concealed = conceal()
if s ~= nil and not concealed.state then
return "Working on " .. s
else
return nil
end
end,
git_commit_text = "Committing changes",
plugin_manager_text = "Managing Plugins",
})
end,
},
}