vyfor / cord.nvim

🚀 Discord Rich Presence plugin for Neovim written in Rust
Apache License 2.0
81 stars 7 forks source link

How to use the `editor` config? #83

Closed daUnknownCoder closed 2 days ago

daUnknownCoder commented 4 days ago

I am working on my own Neovim Distro, i have it in my $NVIM_APPNAME but idk how to use editor.image (i made a logo)? should i add a file location? [like ~/Downloads/img.png?] coz i dont have it hosted online anywhere

if my client name is NeutronVim what should i keep in editor.client? [NeutronVim or neutronvim (as in readme)]

will cord be able to see-through things? like i open nvim-tree and it updates, i open lazy it updates, i open telescope it updates?

in this:

   {
     lazy = {                                 -- Vim filetype or file name or file extension = table or string
       name = 'Lazy',                         -- Optional override for the icon name, redundant for language types
       icon = 'https://example.com/lazy.png', -- Rich Presence asset name or URL
       tooltip = 'lazy.nvim',                 -- Text to display when hovering over the icon
       type = 2,
     },
     ['Cargo.toml'] = 'crates',
  },

so can i overcome the previous problem i had with jiriks's presence plugin (he forked over the unmaintained andweeb version)?: jiriks74/presence.nvim#44

        file_assets = {
          conf = { "Hyprland", "https://styles.redditmedia.com/t5_6sciw0/styles/communityIcon_h3cvittvupi91.png" },
        },
vyfor commented 4 days ago

Hello! Thanks for reaching out!

if my client name is NeutronVim what should i keep in editor.client? [NeutronVim or neutronvim (as in readme)]

You will need to create a Discord Application. The rich presence's name is determined by the name of that application (Playing XYZ). You will then need to copy the application's ID and set editor.client to that ID.

coz i dont have it (the image) hosted online anywhere

The image has to be hosted somewhere online. If you use a third-party hosting service, you can provide a direct URL to the icon in editor.image. Or, you can upload the image as an asset under your application's Rich Presence -> Art Assets section and simply provide the name of the asset. Do note that it may take a while for Discord to update its file cache.

And regarding the linked issue, I haven't used Hyprland personally, but from my research, the configuration file appears to be named as hyprland.conf. If this naming is consistent, you could configure it as follows:

editor = {
  image = 'https://...',
  client = '01234567890',
},
assets = {
  ['hyprland.conf'] = 'https://...',

  -- ['hyprland.conf'] = {
  --   icon = 'https://...',
  --   tooltip = 'Hyprland Config', -- Optionally set a tooltip
  -- },
},

I hope this helps! If you have any more questions, feel free to ask.

daUnknownCoder commented 4 days ago

I haven't used Hyprland personally, but from my research, the configuration file appears to be named as hyprland.conf

It should be anything under the ~/.config/hypr with hypr*.conf

vyfor commented 4 days ago

Hm, it seems that this would require an additional check for the entire path and a way to match against patterns, which Cord does not currently support, as it may introduce unwanted overhead and make the codebase a bit too complex. Are there any other common names for the config file besides hyprland.conf and hypr.conf? You could provide the same icon for each of them.

daUnknownCoder commented 4 days ago

like anything under ~/.config/hypr falls under the jurisdiction of hyprland (theres also a treesitter grammer made only for hyprland (hyprlang) -> an lsp is also in the works (hyprls)

vyfor commented 3 days ago

That requires iterating over the table until a match is found, which seems to be a performance bottleneck (current implementation uses a simple table lookup), given that it runs on each presence update. One thing we can do is introduce two new fields to the configuration, one, where you specify the directories to be searched and one for pattern matching. To avoid cluttering, I'd have them organized into one general field as follows:

assets = {
  ids = {}, -- regular assets are moved here
  dirs = {},
  patterns = {},
}

But that would be a breaking change to the configuration structure. I could inform the users in the commit's description, and/or support the old way of defining assets alongside the new way, although I'm not very fond of this idea. What do you think?

daUnknownCoder commented 3 days ago

i guess theres no need for breaking stuff...

image

so vim.bo.filetype results in hyprlang

so this code snippet works for me:

      assets = {
        lazy = {
          name = "Lazy",
          icon = "https://avatars.githubusercontent.com/u/122150220?s=200&v=4",
          tooltip = "lazy.nvim",
          type = 2,
        },
        hyprlang = {
          name = "Hyprland",
          icon = "https://styles.redditmedia.com/t5_6sciw0/styles/communityIcon_h3cvittvupi91.png",
          tooltip = "Hyprland",
          type = 1,
        },
      },
daUnknownCoder commented 3 days ago

Heyo i found a bug... 🐞

when doing config.display.swap_icons = true, the icons do switch but the tooltips dont 2024-07-06-155912_hyprshot

it doesnt change from lua to the superior text editor or whatever the text was...

vyfor commented 3 days ago

i guess theres no need for breaking stuff...

I'll still have to implement those two in the near future, but we can put it off for the time being if the treesitter approach is working for you.

when doing config.display.swap_icons = true, the icons do switch but the tooltips dont

Whoops, can confirm. Looks like I forgot to reassign the two. I'll push a fix asap.

daUnknownCoder commented 3 days ago

and yeah the buttons thing doesnt work my config:

  {
    "vyfor/cord.nvim",
    build = "./build",
    event = "VeryLazy",
    opts = {
      display = {
        show_cursor_position = true,
        swap_icons = true,
      },
      editor = {
        image = "untitled_design_6_1_",
        client = "1258853126916800655",
      },
      lsp = {
        show_problem_count = true,
        scope = "buffer",
      },
      assets = {
        lazy = {
          name = "Lazy",
          icon = "https://avatars.githubusercontent.com/u/122150220?s=200&v=4",
          tooltip = "lazy.nvim",
          type = 2,
        },
        hyprlang = {
          name = "Hyprland",
          icon = "https://styles.redditmedia.com/t5_6sciw0/styles/communityIcon_h3cvittvupi91.png",
          tooltip = "Hyprland",
          type = 1,
        },
      },
      buttons = {
        {
          label = "View Repository",
          url = "git",
        },
      },
    },
  },

i mean it can be i dont know how to do it or im doing it wrong coz i also checked ur dotfiles and can confirm its not working for me

vyfor commented 3 days ago

If you've received the new UI update related to user profiles, I believe the issue lies within the Discord client itself, as I'm experiencing the same thing. Perhaps you could ask a friend to confirm whether the button appears for them.

daUnknownCoder commented 3 days ago

If you've received the new UI update related to user profiles, I believe the issue lies within the Discord client itself, as I'm experiencing the same thing. Perhaps you could ask a friend to confirm whether the button appears for them.

the 0.0.58 discord patch right?? none of my friends use linux 🫠, i am the lone wolf who overcome the adversity of linux cli, perhaps you can switch window managers? i only use hyprland so i have no other manager and the time it would take would be a waste

vyfor commented 3 days ago

No, what I mean is to ask someone on Discord to check whether you actually have the buttons on your Rich Presence, as this may be a bug on the client-side. If that does not help, try to replace git with the actual repository url, in case it fails to fetch it from the config.

vyfor commented 3 days ago

Pushed a fix to master. config.display.swap_icons should behave correctly now. Do you have any other questions?

daUnknownCoder commented 3 days ago

Pushed a fix to master. config.display.swap_icons should behave correctly now. Do you have any other questions?

that was quick (it works)

daUnknownCoder commented 3 days ago

No, what I mean is to ask someone on Discord to check whether you actually have the buttons on your Rich Presence, as this may be a bug on the client-side. If that does not help, try to replace git with the actual repository url, in case it fails to fetch it from the config.

i just launched discord on my browser and there's no sign of the button (i also tried switching accounts and accessing my account thru my alt which failed)

i also tried this:

      buttons = {
        {
          label = "View Repository",
          url = "https://github.com/daUnknownCoder/NeutronVim",
        },
      },
vyfor commented 3 days ago

Well that's strange, there are no issues on my end: image

Do you mind continuing this conversation on Discord? I go by vyfor

vyfor commented 2 days ago

i just launched discord on my browser and there's no sign of the button (i also tried switching accounts and accessing my account thru my alt which failed)

I'll be closing the issue as it turned out to be a bug on Discord's side. Feel free to open a new one if you have any other questions.