[vim/vim] Cannot use the stdin and stdout of Vim as a channel (PR #21245)

7 views
Skip to first unread message

h_east

unread,
Sep 7, 2026, 8:38:25 AM (4 days ago) Sep 7
to vim/vim, Subscribed
Problem:  A Vim started by another program cannot talk to it over its
          stdin and stdout the way a language server does; a script has
          to make it connect to a socket instead.
Solution: Add the --stdio-channel argument and the "stdio" address for
          ch_open().  Vim then serves the channel instead of reading Ex
          commands and exits when it is closed.  Stdin and stdout are
          redirected to the null device so that other output cannot get
          into the channel.

With --stdio-channel Vim can be the process at the other end of a channel:
it is started by another program and talks to it over its own stdin and
stdout, the way language servers and other tools do. Until now a Vim that
had to serve another process needed a socket, and a script to set up the
connection on both sides.

What this makes possible:

  • A language server for Vim script, written in Vim script. The server runs
    in a Vim, so it can use getcompletion(), the help files and the user's
    'runtimepath' to answer requests. Any editor whose LSP client speaks stdio
    can start it with vim --stdio-channel -S server.vim; no client-side
    support for sockets is needed.

  • Vim as a worker for Vim. A child Vim can be started with job_start() like
    any other job and used in JSON mode, to run slow Vim script or a large
    search and replace without blocking the editor, or to run code that may
    crash without taking the editor down.

  • Embedding Vim in other programs. A Python or Node program can start a Vim
    and drive it through the existing channel commands ("ex", "normal", "call",
    "expr") in one session, instead of a temporary file and a new vim -es for
    every step.

  • Testing. The state of a child Vim can be queried directly over the
    channel, without a terminal or a Python test server in between.

The change reuses the existing channel code: the two file descriptors are
handed to channel_set_pipes() and the "lsp" and "json" modes work unchanged.
After the channel is opened the stdin and stdout of Vim point at the null
device, so messages from Vim and from commands it starts cannot corrupt the
protocol; stderr is left for error messages. Works on Unix and MS-Windows.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21245

Commit Summary

  • 3412e6a Cannot use the stdin and stdout of Vim as a channel

File Changes

(8 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21245@github.com>

Christian Brabandt

unread,
Sep 7, 2026, 2:30:19 PM (4 days ago) Sep 7
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21245)

thanks, can you please also update runtime/doc/vim.1?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21245/c5574437285@github.com>

h_east

unread,
Sep 7, 2026, 3:39:13 PM (4 days ago) Sep 7
to vim/vim, Subscribed
h-east left a comment (vim/vim#21245)

thanks, can you please also update runtime/doc/vim.1?

Done.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21245/c5574972244@github.com>

Christian Brabandt

unread,
Sep 8, 2026, 2:48:32 PM (3 days ago) Sep 8
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21245)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21245/c5590149547@github.com>

Reply all
Reply to author
Forward
0 new messages