*channel.txt* For Vim version 9.0. Last change: 2022 Jun 23
VIM REFERENCE MANUAL by Bram Moolenaar
Inter-process communication *channel*
Vim uses channels to communicate with other processes.
A channel uses a socket or pipes. *socket-interface*
Jobs can be used to start processes and communicate with them.
The Netbeans interface also uses a channel. |netbeans|
1. Overview |job-channel-overview|
2. Channel demo |channel-demo|
3. Opening a channel |channel-open|
4. Using a JSON or JS channel |channel-use|
5. Channel commands |channel-commands|
6. Using a RAW or NL channel |channel-raw|
7. More channel functions |channel-more|
8. Channel functions details |channel-functions-details|
9. Starting a job with a channel |job-start|
10. Starting a job without a channel |job-start-nochannel|
11. Job functions |job-functions-details|
12. Job options |job-options|
13. Controlling a job |job-control|
14. Using a prompt buffer |prompt-buffer|
15. Language Server Protocol |language-server-protocol|
*E1277*
{only when compiled with the |+channel| feature for channel stuff}
You can check this with: `has('channel')`
{only when compiled with the |+job| feature for job stuff}
You can check this with: `has('job')`
==============================================================================
1. Overview *job-channel-overview*
There are four main types of jobs:
1. A daemon, serving several Vim instances.
Vim connects to it with a socket.
2. One job working with one Vim instance, asynchronously.
Uses a socket or pipes.
3. A job performing some work for a short time, asynchronously.
Uses a socket or pipes.
4. Running a filter, synchronously.
Uses pipes.
For when using sockets See |job-start|, |job-start-nochannel| and
|channel-open|. For 2 and 3, one or more jobs using pipes, see |job-start|.
For 4 use the ":{range}!cmd" command, see |filter|.
Over the socket and pipes these protocols are available:
RAW nothing known, Vim cannot tell where a message ends
NL every message ends in a NL (newline) character
JSON JSON encoding |json_encode()|
JS JavaScript style JSON-like encoding |js_encode()|
LSP Language Server Protocol encoding |language-server-protocol|
Common combination are:
- Using a job connected through pipes in NL mode. E.g., to run a style
checker and receive errors and warnings.
- Using a daemon, connecting over a socket in JSON mode. E.g. to lookup
cross-references in a database.
==============================================================================
2. Channel demo *channel-demo* *demoserver.py*
This requires Python. The demo program can be found in
$VIMRUNTIME/tools/demoserver.py
Run it in one terminal. We will call this T1.
Run Vim in another terminal. Connect to the demo server with: >
let channel = ch_open(