patch 9.2.0600: clientserver method needs to be given as argument
Commit:
https://github.com/vim/vim/commit/c2dd5e1ea746b556844544aa340937f0cf0f33a0
Author: Foxe Chen <[email protected]>
Date: Fri Jun 5 17:41:26 2026 +0000
patch 9.2.0600: clientserver method needs to be given as argument
Problem: clientserver method needs to be given as argument
Solution: Add support for the $VIM_CLIENTSERVER environment variable,
which defines which clientserver method Vim should use
(Foxe Chen).
closes: #20409
Signed-off-by: Foxe Chen <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt
index 260fc864f..d33c14eb5 100644
--- a/runtime/doc/remote.txt
+++ b/runtime/doc/remote.txt
@@ -1,4 +1,4 @@
-*remote.txt* For Vim version 9.2. Last change: 2026 Feb 14
+*remote.txt* For Vim version 9.2. Last change: 2026 Jun 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -80,11 +80,17 @@ The following command line arguments are available:
--clientserver {method} Use the specified method {method} as the
backend for clientserver functionality. Can
either be "socket", "x11", or "mswin".
+ *$VIM_CLIENTSERVER*
+ If the "$VIM_CLIENTSERVER" environment
+ variable is set, then Vim will interpret the
+ value just like the --clientserver argument.
+ If it is set and --clientserver is provided in
+ the command line, then --clientserver takes
+ priority.
{only available when compiled with both |+X11|
and |+socketserver| features, or
|+socketserver| on MS-Windows}
-
Examples ~
Edit "file.txt" in an already running GVIM server: >
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 21ad16a14..33c6daa42 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -13,6 +13,7 @@ $NoDefaultCurrentDirectoryInExePath builtin.txt
/*$NoDefaultCurrentDirectoryInEx
$VIM starting.txt /*$VIM*
$VIM-use version5.txt /*$VIM-use*
$VIMRUNTIME starting.txt /*$VIMRUNTIME*
+$VIM_CLIENTSERVER remote.txt /*$VIM_CLIENTSERVER*
$VIM_POSIX vi_diff.txt /*$VIM_POSIX*
$XDG_CONFIG_HOME starting.txt /*$XDG_CONFIG_HOME*
$quote eval.txt /*$quote*
diff --git a/runtime/doc/vim.1 b/runtime/doc/vim.1
index fbc425250..93c28d6ac 100644
--- a/runtime/doc/vim.1
+++ b/runtime/doc/vim.1
@@ -1,4 +1,4 @@
-.TH VIM 1 "2026 May 22"
+.TH VIM 1 "2026 Jun 05"
.SH NAME
vim \- Vi IMproved, a programmer's text editor
.SH SYNOPSIS
@@ -518,7 +518,9 @@ it is taken as either an absolute, relative or relative
path to the socket.
Use {backend} as the backend for clientserver functionality, either "socket",
"x11", or "mswin" respectively. Only available when compiled with both
socketserver and X11 features present, or if compiled with socketserver on
-MS-Windows.
+MS-Windows. The $VIM_CLIENTSERVER environment variable may also be set which
+will be interpreted in the same way, but the --clientserver argument will
always
+take priority.
.TP
\-\-socketid {id}
GTK GUI only: Use the GtkPlug mechanism to run gVim in another window.
diff --git a/runtime/doc/vim.man b/runtime/doc/vim.man
index c3bc78c2f..583d9d28f 100644
--- a/runtime/doc/vim.man
+++ b/runtime/doc/vim.man
@@ -390,11 +390,13 @@ OPTIONS
to the socket.
--clientserver {backend}
- Use {backend} as the backend for clientserver functional‐
+ Use {backend} as the backend for clientserver functional‐
ity, either "socket", "x11", or "mswin" respectively. Only
available when compiled with both socketserver and X11 fea‐
- tures present, or if compiled with socketserver on MS-Win‐
- dows.
+ tures present, or if compiled with socketserver on MS-Win‐
+ dows. The $VIM_CLIENTSERVER environment variable may also
+ be set which will be interpreted in the same way, but the
+ --clientserver argument will always take priority.
--socketid {id}
GTK GUI only: Use the GtkPlug mechanism to run gVim in an‐
@@ -493,4 +495,4 @@ BUGS
vi_diff.txt when in Vim). Also have a look at the 'compatible' and
'cpoptions' options.
- 2026 May 22 VIM(1)
+ 2026 Jun 05 VIM(1)
diff --git a/src/clientserver.c b/src/clientserver.c
index ae72a694f..5b0d4a2df 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -1276,3 +1276,28 @@ f_serverlist(typval_T *argvars UNUSED, typval_T *rettv)
rettv->vval.v_string = r;
}
#endif
+
+#ifdef FEAT_CLIENTSERVER_BACKENDS
+/*
+ * Check the $VIM_CLIENTSERVER environment variable and set the method
+ */
+ void
+check_clientserver_method_env(void)
+{
+ char_u *env = mch_getenv("VIM_CLIENTSERVER");
+
+ if (env == NULL)
+ return;
+
+ if (STRICMP(env, "socket") == 0)
+ clientserver_method = CLIENTSERVER_METHOD_SOCKET;
+# ifdef FEAT_X11
+ else if (STRICMP(env, "x11") == 0)
+ clientserver_method = CLIENTSERVER_METHOD_X11;
+# endif
+# ifdef MSWIN
+ else if (STRICMP(env, "mswin") == 0)
+ clientserver_method = CLIENTSERVER_METHOD_MSWIN;
+# endif
+}
+#endif
diff --git a/src/main.c b/src/main.c
index d2fe22ebe..e30012be4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1038,6 +1038,13 @@ common_init_2(mparm_T *paramp)
gui.dofork = true; // default is to use fork()
#endif
+#ifdef FEAT_CLIENTSERVER_BACKENDS
+ /*
+ * Check the $VIM_CLIENTSERVER env before we handle the --clientserver arg
+ */
+ check_clientserver_method_env();
+#endif
+
/*
* Do a first scan of the arguments in "argv[]":
* -display or --display
diff --git a/src/proto/clientserver.pro b/src/proto/clientserver.pro
index 3acd5e01e..2c71b130e 100644
--- a/src/proto/clientserver.pro
+++ b/src/proto/clientserver.pro
@@ -13,4 +13,5 @@ void f_remote_send(typval_T *argvars, typval_T *rettv);
void f_remote_startserver(typval_T *argvars, typval_T *rettv);
void f_server2client(typval_T *argvars, typval_T *rettv);
void f_serverlist(typval_T *argvars, typval_T *rettv);
+void check_clientserver_method_env(void);
/* vim: set ft=c : */
diff --git a/src/testdir/test_clientserver.vim
b/src/testdir/test_clientserver.vim
index 15918f726..754aa7730 100644
--- a/src/testdir/test_clientserver.vim
+++ b/src/testdir/test_clientserver.vim
@@ -498,6 +498,48 @@ func Test_clientserver_socketserver_invalid_msg()
call StopVimInTerminal(buf)
endfunc
+" Test that $VIM_CLIENTSERVER env var works properly
+func Test_clientserver_env_method()
+ CheckFeature socketserver
+
+ let g:test_is_flaky = 1
+ let cmd = GetVimCommand()
+
+ if cmd == ''
+ throw 'GetVimCommand() failed'
+ endif
+
+ " Don't use channel:2000, because previous tests use that and it may take a
+ " while for the channel to fully close.
+ let actual = cmd .. ' --servername channel:4000'
+ let $VIM_CLIENTSERVER = 'socket'
+
+ let job = job_start(actual, {'stoponexit': 'kill', 'out_io': 'null'})
+
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
+
+ if !has('win32') || !has('gui_running')
+ call assert_match('channel:4000',
+ \ system(actual .. ' --remote-expr "v:servername"'))
+ endif
+
+ if has('win32')
+ call job_stop(job, 'kill')
+ else
+ call system(actual .. " --remote-expr 'execute(\"qa!\")'")
+ endif
+ unlet $VIM_CLIENTSERVER
+
+ try
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
+ finally
+ if job_status(job) != 'dead'
+ call assert_report('Server did not exit')
+ call job_stop(job, 'kill')
+ endif
+ endtry
+endfunc
+
" Uncomment this line to get a debugging log
" call ch_logfile('channellog', 'w')
diff --git a/src/version.c b/src/version.c
index 669a5cf03..a58178aed 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 600,
/**/
599,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1wVYpy-007Ag9-M0%40256bit.org.