aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc/server.c
diff options
context:
space:
mode:
authorGhjuvan Lacambre <code@lacamb.re>2023-02-16 13:15:02 +0100
committerGitHub <noreply@github.com>2023-02-16 04:15:02 -0800
commitd34c64e342dfba9248d1055e702d02620a1b31a8 (patch)
treea685ef816f1621092ec82ea17d22fbd3a8c03957 /src/nvim/msgpack_rpc/server.c
parent631775c05d257e5e61af31d20d9fd5be2dba82c2 (diff)
downloadrneovim-d34c64e342dfba9248d1055e702d02620a1b31a8.tar.gz
rneovim-d34c64e342dfba9248d1055e702d02620a1b31a8.tar.bz2
rneovim-d34c64e342dfba9248d1055e702d02620a1b31a8.zip
feat: $NVIM_APPNAME #22128
This commit implements the ability to control all of the XDG paths Neovim should use. This is done by setting an environment variable named NVIM_APPNAME. For example, setting $NVIM_APPNAME makes Neovim look for its configuration directory in $XDG_CONFIG_HOME/$NVIM_APPNAME instead of $XDG_CONFIG_HOME/nvim. If NVIM_APPNAME is not set or is an empty string, "nvim" will be used as default. The usecase for this feature is to enable an easy way to switch from configuration to configuration. One might argue that the various $XDG environment variables can already be used for this usecase. However, setting $XDG environment variables also affects tools spawned by Neovim. For example, while setting $XDG_CONFIG_HOME will enable Neovim to use a different configuration directory, it will also prevent Git from finding its "default" configuration. Closes https://github.com/neovim/neovim/issues/21691
Diffstat (limited to 'src/nvim/msgpack_rpc/server.c')
-rw-r--r--src/nvim/msgpack_rpc/server.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c
index 1d75c208be..c6a0a4d8cc 100644
--- a/src/nvim/msgpack_rpc/server.c
+++ b/src/nvim/msgpack_rpc/server.c
@@ -91,13 +91,14 @@ char *server_address_new(const char *name)
{
static uint32_t count = 0;
char fmt[ADDRESS_MAX_SIZE];
+ const char *appname = get_appname();
#ifdef MSWIN
int r = snprintf(fmt, sizeof(fmt), "\\\\.\\pipe\\%s.%" PRIu64 ".%" PRIu32,
- name ? name : "nvim", os_get_pid(), count++);
+ name ? name : appname, os_get_pid(), count++);
#else
char *dir = stdpaths_get_xdg_var(kXDGRuntimeDir);
int r = snprintf(fmt, sizeof(fmt), "%s/%s.%" PRIu64 ".%" PRIu32,
- dir, name ? name : "nvim", os_get_pid(), count++);
+ dir, name ? name : appname, os_get_pid(), count++);
xfree(dir);
#endif
if ((size_t)r >= sizeof(fmt)) {