1- *channel.txt* For Vim version 9.2. Last change: 2026 Feb 18
1+ *channel.txt* For Vim version 9.2. Last change: 2026 Feb 25
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -26,6 +26,7 @@ The Netbeans interface also uses a channel. |netbeans|
262613. Controlling a job | job-control |
272714. Using a prompt buffer | prompt-buffer |
282815. Language Server Protocol | language-server-protocol |
29+ 16. Debug Adapter Protocol | debug-adapter-protocol |
2930
3031 *E1277*
3132{only when compiled with the | +channel | feature for channel stuff}
@@ -56,6 +57,7 @@ NL every message ends in a NL (newline) character
5657JSON JSON encoding | json_encode() |
5758JS JavaScript style JSON-like encoding | js_encode() |
5859LSP Language Server Protocol encoding | language-server-protocol |
60+ DAP Debug Adapter Protocol encoding | debug-adapter-protocol |
5961
6062Common combination are:
6163- Using a job connected through pipes in NL mode. E.g., to run a style
@@ -143,6 +145,7 @@ unreachable on the network.
143145 "nl" - Use messages that end in a NL character
144146 "raw" - Use raw messages
145147 "lsp" - Use language server protocol encoding
148+ "dap" - Use debug adapter protocol encoding
146149 *channel-callback* *E921*
147150"callback" A function that is called when a message is received that is
148151 not handled otherwise (e.g. a JSON message with ID zero). It
@@ -153,8 +156,9 @@ unreachable on the network.
153156 endfunc
154157 let channel = ch_open("localhost:8765", {"callback": "Handle"})
155158<
156- When "mode" is "json" or "js" or "lsp" the "msg" argument is
157- the body of the received message, converted to Vim types.
159+ When "mode" is any of "json", "js", "lsp" or "dap" the "msg"
160+ argument is the body of the received message, converted to Vim
161+ types.
158162 When "mode" is "nl" the "msg" argument is one message,
159163 excluding the NL.
160164 When "mode" is "raw" the "msg" argument is the whole message
@@ -537,16 +541,17 @@ ch_evalexpr({handle}, {expr} [, {options}]) *ch_evalexpr()*
537541 according to the type of channel. The function cannot be used
538542 with a raw channel. See | channel-use | .
539543 {handle} can be a Channel or a Job that has a Channel.
540- When using the "lsp" channel mode, {expr} must be a | Dict | .
544+ When using the "lsp" or "dap" channel mode, {expr} must be a
545+ | Dict | .
541546 *E917*
542547 {options} must be a Dictionary. It must not have a "callback"
543548 entry. It can have a "timeout" entry to specify the timeout
544549 for this specific request.
545550
546551 ch_evalexpr() waits for a response and returns the decoded
547552 expression. When there is an error or timeout it returns an
548- empty | String | or, when using the "lsp" channel mode, returns an
549- empty | Dict | .
553+ empty | String | or, when using the "lsp" or "dap" channel mode,
554+ returns an empty | Dict | .
550555
551556 Note that while waiting for the response, Vim handles other
552557 messages. You need to make sure this doesn't cause trouble.
@@ -627,7 +632,7 @@ ch_info({handle}) *ch_info()*
627632 "err_io" "out", "null", "pipe", "file" or "buffer"
628633 "err_timeout" timeout in msec
629634 "in_status" "open" or "closed"
630- "in_mode" "NL", "RAW", "JSON", "JS" or "LSP"
635+ "in_mode" "NL", "RAW", "JSON", "JS" or "LSP" or "DAP"
631636 "in_io" "null", "pipe", "file" or "buffer"
632637 "in_timeout" timeout in msec
633638
@@ -733,14 +738,15 @@ ch_sendexpr({handle}, {expr} [, {options}]) *ch_sendexpr()*
733738 with a raw channel.
734739 See | channel-use | . *E912*
735740 {handle} can be a Channel or a Job that has a Channel.
736- When using the "lsp" channel mode, {expr} must be a | Dict | .
741+ When using the "lsp" or "dap" channel mode, {expr} must be a
742+ | Dict | .
737743
738- If the channel mode is "lsp", then returns a Dict. Otherwise
739- returns an empty String. If the "callback" item is present in
740- {options} , then the returned Dict contains the ID of the
741- request message. The ID can be used to send a cancellation
742- request to the LSP server (if needed). Returns an empty Dict
743- on error.
744+ If the channel mode is "lsp" or "dap" , then returns a Dict.
745+ Otherwise returns an empty String. If the "callback" item is
746+ present in {options} , then the returned Dict contains the ID
747+ of the request message. The ID can be used to send a
748+ cancellation request to the LSP server or debug adapter (if
749+ needed). Returns an empty Dict on error.
744750
745751 If a response message is not expected for {expr} , then don't
746752 specify the "callback" item in {options} .
@@ -1607,5 +1613,33 @@ The "params" field is optional: >
16071613 "params": <list|dict>
16081614 }
16091615
1610- <
1616+ ==============================================================================
1617+ 16. Debug Adapter Protocol *debug-adapter-protocol*
1618+
1619+ The debug adapter protocol is very similar to the language server protocol,
1620+ with the main difference being that it does not use the JSON-RPC format. The
1621+ specification can be found here:
1622+
1623+ https://microsoft.github.io/debug-adapter-protocol/specification
1624+
1625+ The protocol uses the same header format as the LSP protocol.
1626+
1627+ To encode and send a DAP request/notification message in a Vim | Dict | into a
1628+ JSON message and to receive and decode a DAP JSON response/notification
1629+ message into a Vim | Dict | , connect to the debug adapter with the
1630+ | channel-mode | set to "dap".
1631+
1632+ For messages received on a channel with | channel-mode | set to "dap", Vim will
1633+ process the HTTP header and decode the JSON payload into a Vim | Dict | type.
1634+ When sending messages on a channel using the | ch_evalexpr() | or
1635+ | ch_sendexpr() | functions, Vim will add the HTTP header and encode the Vim
1636+ expression into JSON.
1637+
1638+ Vim will automatically add the "seq" field to the JSON DAP message, and manage
1639+ the "request_seq" field as well for responses. However it will not add the
1640+ "type" field, it should be manually specified in the | Dict | .
1641+
1642+ Otherwise the behaviour is the same as how Vim handles the "lsp" channel mode
1643+ | language-server-protocol | .
1644+
16111645 vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments