feat(nvim): minor updates to the presence plugin

This commit is contained in:
winston 2022-12-07 09:30:23 +01:00
parent 5c1dc69b05
commit 319151ee02
Signed by: winston
GPG key ID: 3786770EDBC2B481
2 changed files with 49 additions and 16 deletions

View file

@ -2,15 +2,32 @@ function string.starts(self, str)
return self:find("^" .. str) ~= nil return self:find("^" .. str) ~= nil
end end
local conceal = function() local home = vim.fn.expand("$HOME") .. "/Code/"
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.",
[vim.fn.resolve(vim.fn.stdpath("config"))] = "Stuck in the hell of nvim config.",
}
local blacklist = {
[vim.fn.resolve(home .. "work")] = "Using nvim at work.",
[vim.fn.resolve(home .. "freelance")] = "Using nvim to freelance.",
}
local function get_chezmoi_output()
local sp = io.popen("chezmoi managed -i files")
if sp then
local files = {}
for line in sp:lines() do
table.insert(files, vim.fn.expand("$HOME") .. "/" .. line)
end
sp:close()
return files
end
end
local chezmoi_managed = get_chezmoi_output()
local conceal = function()
local cur_file = vim.fn.expand("%:p") local cur_file = vim.fn.expand("%:p")
if vim.tbl_contains(chezmoi_managed, cur_file) then
return "Managing dotfiles"
end
for k, v in pairs(blacklist) do for k, v in pairs(blacklist) do
if cur_file:starts(k) then if cur_file:starts(k) then
return v return v
@ -19,12 +36,17 @@ local conceal = function()
return false return false
end end
local v = vim.version()
local vStr = string.format("v%d.%d.%d", v.major, v.minor, v.patch)
require("presence"):setup({ require("presence"):setup({
-- General options -- General options
auto_update = true, auto_update = true,
neovim_image_text = "The Soydev's Kryptonite", debounce_timeout = 10,
neovim_image_text = "Masochism " .. vStr,
-- Main image display (either "neovim" or "file") -- Main image display (either "neovim" or "file")
main_image = "file", main_image = "file",
show_time = false,
-- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
buttons = function(buffer, repo_url) buttons = function(buffer, repo_url)
@ -52,14 +74,18 @@ require("presence"):setup({
end end
end end
-- if not, return false -- if not, make funni
return false return {
{
label = "Steal the code",
url = "https://winston.sh/rrproductions/studio.git",
},
}
end, end,
debounce_timeout = 10,
file_assets = { file_assets = {
["k8s.yaml"] = { ["k8s.yaml"] = {
"Kubernetes", "Kubernetes",
"https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png", "https://avatars.githubusercontent.com/u/13629408",
}, },
["Chart.yaml"] = { ["Chart.yaml"] = {
"Helm Chart", "Helm Chart",
@ -73,6 +99,14 @@ require("presence"):setup({
"Prisma", "Prisma",
"https://avatars.githubusercontent.com/u/17219288", "https://avatars.githubusercontent.com/u/17219288",
}, },
["bu"] = {
"Butane Config",
"https://avatars.githubusercontent.com/u/3730757",
},
["ign"] = {
"CoreOS Ignition",
"https://avatars.githubusercontent.com/u/3730757",
},
}, },
-- Rich Presence text options -- Rich Presence text options
editing_text = function(s) editing_text = function(s)
@ -94,17 +128,16 @@ require("presence"):setup({
if concealed then if concealed then
return concealed return concealed
end end
return "Working in " .. s return "Browsing " .. s
end, end,
workspace_text = function(s) workspace_text = function(s)
local concealed = conceal() local concealed = conceal()
if s ~= nil and not concealed then if s ~= nil and not concealed then
return "Working on " .. s return "Working on " .. s
else else
return nil return "Masochism " .. vStr
end end
end, end,
git_commit_text = "Committing changes", git_commit_text = "Committing changes",
plugin_manager_text = "Managing Plugins", plugin_manager_text = "Managing Plugins",
line_number_text = "L%s of %s",
}) })

View file

@ -14,7 +14,7 @@ vim.api.nvim_create_autocmd("BufWritePost", {
}) })
local function check_git() local function check_git()
local is_repo = vim.fn.isdirectory(vim.fn.getcwd() .. "/.git") == 1 local is_repo = vim.fn.filereadable(vim.fn.getcwd() .. "/.git") == 1
local git_exists = vim.fn.executable("git") == 1 local git_exists = vim.fn.executable("git") == 1
return is_repo and git_exists return is_repo and git_exists
end end