andweeb / presence.nvim

Discord Rich Presence for Neovim
811 stars 66 forks source link

[feature] link to repo #27

Closed fabianoSL1 closed 3 years ago

fabianoSL1 commented 3 years ago

a button that takes you to the repository like coc-discord-rpc.

andweeb commented 3 years ago

Whoa what! I didn't know this was possible, thanks for letting me know 🙆 I'll look into this.

andweeb commented 3 years ago

Just pushed a change to show a View Repository button for the current workspace if applicable (enabled by default), along with a config option to allow for enabling, disabling, or configuring custom static or dynamic button(s), check it:

-- Disable the buttons feature
require("presence"):setup({ buttons = false })
-- Configure static button(s) that will always be appear in Rich Presence
require("presence"):setup({
    buttons = {
        { label = "GitHub Profile", url = "https://github.com/andweeb" },
        { label = "Check out my dotfiles", url = "https://github.com/andweeb/dotfiles" },
    },
})
-- Configure dynamic button(s) depending on the repo
require("presence"):setup({
    buttons = function(buffer, repo_url)
        local button = {
            label = "Look at my code!",
            url = repo_url,
        }

        if repo_url:match("presence.nvim") then
            button.label = "Check out my Discord plugin!",
        elseif repo_url:match("dotfiles") then
            button.label = "Look I be ricing",
        end

        return {button}
    end,
})

I've updated the demo in the README to display this, thanks for letting me know about this feature! 🙆‍♂️