presence.nvim
presence.nvim copied to clipboard
presence.nvim doesn't start, getting an exception instead
Description
I followed the installation steps but I'm getting an exception instead and Discord shows nothing.
Error executing vim.schedule lua callback: ...te/pack/packer/start/presence.nvim/lua/presence/init.lua:348: attempt to index local 'response' (a nil value)
stack traceback:
...te/pack/packer/start/presence.nvim/lua/presence/init.lua:348: in function 'on_done'
...pack/packer/start/presence.nvim/lua/presence/discord.lua:186: in function <...pack/packer/start/presence.nvim/lua/presence/discord.lua:185>
I don't think it's a problem with my system because elcord.el on Emacs works fine. It looks like the same error as #70 but I'm not using alpha-nvim and I tested it with a minimal configuration.
There's my config:
local use = require('packer').use
require('packer').startup(
function()
use 'wbthomason/packer.nvim' -- Package manageruse
use 'andweeb/presence.nvim'
end
)
-- The setup config table shows all available config options with their default values:
require("presence"):setup({
-- General options
auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`)
neovim_image_text = "The One True Text Editor", -- Text displayed when hovered over the Neovim image
main_image = "neovim", -- Main image display (either "neovim" or "file")
client_id = "793271441293967371", -- Use your own Discord application client id (not recommended)
log_level = "debug", -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
enable_line_number = false, -- Displays the current line number instead of the current project
blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
file_assets = {}, -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
show_time = true, -- Show the timer
-- Rich Presence text options
editing_text = "Editing %s", -- Format string rendered when an editable file is loaded in the buffer (either string or function(filename: string): string)
file_explorer_text = "Browsing %s", -- Format string rendered when browsing a file explorer (either string or function(file_explorer_name: string): string)
git_commit_text = "Committing changes", -- Format string rendered when committing changes in git (either string or function(filename: string): string)
plugin_manager_text = "Managing plugins", -- Format string rendered when managing plugins (either string or function(plugin_manager_name: string): string)
reading_text = "Reading %s", -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer (either string or function(filename: string): string)
workspace_text = "Working on %s", -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string)
line_number_text = "Line %s out of %s", -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string)
})
Neovim version
NVIM v0.8.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
OS information
fedora 36
Steps to reproduce
- Follow the installation steps.
- Open a file.
Logs
[presence.nvim] Setting up plugin for linux
[presence.nvim] Using user-defined Discord client id
[presence.nvim] Using runtime path: /run/user/1000
[presence.nvim] Using Discord IPC socket path: /run/user/1000/discord-ipc-0
[presence.nvim] Checking Discord IPC socket at /run/user/1000/discord-ipc-0...
[presence.nvim] Using id 98584a77-cb5a-487f-96c0-bc52a0867ef7
[presence.nvim] Completed plugin setup
[presence.nvim] Getting nvim socket paths...
[presence.nvim] Executing command: ss -lx|grep "nvim.*/0"
[presence.nvim] Checked Discord IPC socket, looks good!
[presence.nvim] Handling BufEnter event...
[presence.nvim] Connecting to Discord...
[presence.nvim] Connected to Discord
[presence.nvim] Authorizing with Discord...
[presence.nvim] Wrote message to pipe
[presence.nvim] Got nvim socket paths: {}
[presence.nvim] No other remote nvim instances
Error executing vim.schedule lua callback: ...te/pack/packer/start/presence.nvim/lua/presence/init.lua:348: attempt to index local 'response' (a nil value)
stack traceback:
...te/pack/packer/start/presence.nvim/lua/presence/init.lua:348: in function 'on_done'
...pack/packer/start/presence.nvim/lua/presence/discord.lua:186: in function <...pack/packer/start/presence.nvim/lua/presence/discord.lua:185>
Same error on Gentoo and NVIM 0.9.0
I think I found the issue, the logging function on line 358 (provided below) in presence/init.lua indexes a nil value that may not be provided, removing the line makes the program work as intended
self.log:info(string.format("Authorized with Discord for %s", response.data.user.username))
Same issue here, on Arch and Neovim v0.9.1. Nearly identical error trace; the relevant line has moved slightly, but it's the same code that @isopropyletherperoxide indicated above.
Prior to experiencing this issue, I had not changed anything in my configuration (or even updated this extension, though doing that doesn't resolve the issue either). Maybe something has changed on Discord's end?
Same error and for me it only crashes when discord is open
Yep. That should be because it doesn't try to talk to Discord when the latter is closed.
well the crash happens cause response is nil so i added nil protection
Adding this bit of code will fix it, don't know a thing about lua but just adding a protection if response != nil fixed it.
if response ~= nil then
self.log:info(string.format("Authorized with Discord for %s", response.data.user.username))
self.is_authorized = true
end
I don't know if this is happening with anyone else but after adding nil protection there isn't an error anymore but my RPC is dropping randomly after a little bit of time.
Feels to me like the nil response might indicate a larger issue with authorization (potentially explaining @grififth 's dropped connections?), but I'm unfortunately not familiar enough with Discord to really dig into this.