andweeb / presence.nvim

Discord Rich Presence for Neovim
818 stars 65 forks source link

Fix sudo error on macOS #68

Closed coryshaw1 closed 2 years ago

coryshaw1 commented 2 years ago

When using sudo a separate environment is used unless specifying sudo -E. This fixes the error of path being nil when using neovim in sudo

andweeb commented 2 years ago

Hi @coryshaw1, sorry for the late response! That's a good catch, sudo (env_reset) was definitely an oversight. Apologies for the errors! In macOS, the plugin requires (and assumes) the $TMPDIR environment variable to be preserved, as it's used to determine the path of the Discord IPC socket.

Just as a general note, rather than running sudo nvim or sudo -E nvim, I'd recommend setting your $EDITOR (or $VISUAL) environment variable to nvim and instead use sudo -e to avoid exposing your system to any potential bugs or vulnerabilities involving Neovim. It essentially enables you to edit a temporary copy before it is moved to the original file, which circumvents the default env_reset behavior and allows this plugin to function correctly.

In any case, your changes LGTM so I'll merge em in. Thanks for the PR!