Skip to content

fix: support NVIM_APPNAME in XDG_RUNTIME_DIR socket discovery#49

Merged
Cannon07 merged 1 commit intoCannon07:mainfrom
fky2015:main
May 6, 2026
Merged

fix: support NVIM_APPNAME in XDG_RUNTIME_DIR socket discovery#49
Cannon07 merged 1 commit intoCannon07:mainfrom
fky2015:main

Conversation

@fky2015
Copy link
Copy Markdown
Contributor

@fky2015 fky2015 commented May 6, 2026

Problem

When NVIM_APPNAME is set (e.g. NVIM_APPNAME=lazynvim), Neovim generates
socket filenames using the custom app name instead of "nvim":

  /run/user/<uid>/lazynvim.97652.0

The current glob nvim.*.0 in step 4 fails to discover these sockets.

Root Cause

Neovim's server_address_new() uses get_appname() (which reads
$NVIM_APPNAME, defaulting to "nvim") as the socket filename prefix:

  $XDG_RUNTIME_DIR/$NVIM_APPNAME.$PID.$COUNT

Reference: https://github.com/neovim/neovim/blob/d9a7b687955bd1af377dba56b87479acd7141f87/src/nvim/msgpack_rpc/server.c#L128-L129 and https://github.com/neovim/neovim/blob/d9a7b687955bd1af377dba56b87479acd7141f87/src/nvim/os/stdpaths.c#L71

Fix

Use $NVIM_APPNAME (defaulting to "nvim") to construct the glob pattern
dynamically in the XDG_RUNTIME_DIR scan.

Neovim uses $NVIM_APPNAME (default "nvim") as the socket filename prefix
(e.g. "lazynvim.12345.0" instead of "nvim.12345.0"). The hardcoded
"nvim.*.0" glob fails to discover sockets when NVIM_APPNAME is set.
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for the detailed root-cause analysis and the Neovim source links, it made this trivial to verify.

Merging.

@Cannon07 Cannon07 merged commit 11897cc into Cannon07:main May 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants