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

Skip Discord events if IPC socket is nil

- Update README
- Improve logs when canceling activity
This commit is contained in:
Andrew Kwon 2021-05-05 23:18:04 -07:00
parent 704ea67102
commit 154b8fc5a4
2 changed files with 25 additions and 20 deletions

@ -1,7 +1,8 @@
<img src="https://gist.githubusercontent.com/andweeb/df3216345530234289b87cf5080c2c60/raw/8de399cfed82c137f793e9f580027b5246bc4379/presence.nvim.png" alt="presence.nvim">&#x200B;
===
Discord [Rich Presence](https://discord.com/rich-presence) plugin for Neovim
**[Features](#features)** | **[Installation](#installation)** | **[Configuration](#configuration)** | **[Troubleshooting](#troubleshooting)** | **[Contributing](#contributing)**
> Discord [Rich Presence](https://discord.com/rich-presence) plugin for Neovim
<img src="https://gist.githubusercontent.com/andweeb/df3216345530234289b87cf5080c2c60/raw/4b07351547ae9a6bfdcbc1f915889b90a5349242/presence-demo.gif" alt="demo.gif">
@ -19,12 +20,10 @@ Use your favorite plugin manager
#### Notes
* Requires [Neovim nightly](https://github.com/neovim/neovim/releases/tag/nightly) (0.5)
* Windows is partially supported
* Can update Rich Presence as expected
* Does not yet properly handle multiple running nvim instances
* Windows is [partially supported](https://github.com/andweeb/presence.nvim/projects/1#card-60537963), WSL is [not yet supported](https://github.com/andweeb/presence.nvim/projects/1#card-60537961)
## Configuration
Rich Presence works right out of the box after installation by default, so configuration is optional. For those that do want to override default behaviors, however, configuration options are available in both Lua and VimL.
Rich Presence works right out of the box after installation, so configuration is optional. For those that do want to override default behaviors, however, configuration options are available in either Lua or VimL.
### Lua
Require the plugin and call `setup` with a config table with any of the following keys:
@ -56,16 +55,17 @@ let g:presence_log_level
let g:presence_debounce_timeout = 15
```
## Contributing
Pull requests are very welcome, feel free to open an issue! Here some open todo items:
- [x] Manage workspace state across multiple nvim instances (e.g. tmux)
- [x] Set activity on other autocommands (`TextChanged`, `VimLeavePre`)
- [x] Use named pipes to support Windows
- [ ] Set idle activity (track using `CursorMoved`)
- [ ] Expose file assets table as a configurable option
- [ ] Fix peer-to-peer nvim instance communication in Windows
- [ ] Manage activity properly in buffers in windows and tabs
- [ ] Retry connection after initial setup or a closed pipe (i.e. after quitting Discord app)
- [ ] Attempt to connect to a range of pipes from `discord-ipc-0` to `discord-ipc-9` (see [note](https://github.com/discord/discord-rpc/blob/master/documentation/hard-mode.md#notes))
## Troubleshooting
* Ensure that Discord is running
* Ensure that your Neovim version is on v0.5
* Ensure Game Activity is enabled in your Discord settings
* Enable logging and inspect the logs after opening a buffer
* Set the `log_level` setup option or `g:presence_log_level` to `"debug"`
* Load a file and see the logs with `:messages`
* If there is a `Failed to get Discord IPC socket` error, your particular OS may not yet be supported
* Create a [new issue](https://github.com/andweeb/presence.nvim/issues/new) if one does not exist for your OS yet
Asset additions and changes are also welcome! Supported file types can be found in [`file_assets.lua`](lua/presence/file_assets.lua) and their assets can be found [in this folder](https://www.dropbox.com/sh/j8913f0gav3toeh/AADxjn0NuTprGFtv3Il1Pqz-a?dl=0).
## Contributing
Pull requests are very welcome, feel free to open an issue to work on any of the open [todo items](https://github.com/andweeb/presence.nvim/projects/1?add_cards_query=is%3Aopen)!
Asset additions and changes are also welcome! Supported file types can be found in [`file_assets.lua`](lua/presence/file_assets.lua) and their referenced asset files can be found [in this folder](https://www.dropbox.com/sh/j8913f0gav3toeh/AADxjn0NuTprGFtv3Il1Pqz-a?dl=0).

@ -171,11 +171,11 @@ function Presence:cancel()
self.discord:set_activity(nil, function(err)
if err then
self.log:error("Failed to set nil activity in Discord: "..err)
self.log:error(string.format("Failed to cancel activity in Discord: %s", err))
return
end
self.log:info("Sent nil activity to Discord")
self.log:info("Canceled Discord presence")
end)
end
@ -391,6 +391,11 @@ end
-- Wrap calls to Discord that require prior connection and authorization
function Presence.discord_event(on_ready)
return function(self, ...)
if not self.discord.ipc_socket then
self.log:debug("Discord IPC socket not found, skipping...")
return
end
local args = {...}
local callback = function() on_ready(self, unpack(args)) end