Skip to content

Commit 8ce6a00

Browse files
committed
Update channel.{txt,jax}
1 parent b1b9729 commit 8ce6a00

2 files changed

Lines changed: 99 additions & 35 deletions

File tree

doc/channel.jax

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*channel.txt* For Vim バージョン 9.2. Last change: 2026 Feb 18
1+
*channel.txt* For Vim バージョン 9.2. Last change: 2026 Feb 25
22

33

44
VIM リファレンスマニュアル by Bram Moolenaar
@@ -25,7 +25,8 @@ Netbeans インターフェイスもチャネルを使っています。|netbean
2525
12. ジョブオプション |job-options|
2626
13. ジョブを制御する |job-control|
2727
14. プロンプトバッファを使う |prompt-buffer|
28-
15. Language Server Protocol |language-server-protocol|
28+
15. 言語サーバープロトコル |language-server-protocol|
29+
16. デバッグアダプタープロトコル |debug-adapter-protocol|
2930

3031
*E1277*
3132
{Vim が |+channel| 機能付きでコンパイルされたときのみ有効}
@@ -54,6 +55,7 @@ NL すべてのメッセージは NL (改行) 文字で終わります。
5455
JSON JSON エンコーディング |json_encode()|
5556
JS JavaScript スタイルの JSON 風のエンコーディング |js_encode()|
5657
LSP Language Server Protocol のエンコーディング |language-server-protocol|
58+
DAP Debug Adapter Protocol のエンコーディング |debug-adapter-protocol|
5759

5860
共通の組み合わせ:
5961
- NL モードでパイプを介して接続されたジョブを使用します。例えば、スタイルチェッ
@@ -142,6 +144,7 @@ send を呼ぶたびに毎回コールバックを指定する代わりに、チ
142144
"nl" - NL 文字で終わるメッセージを使う
143145
"raw" - raw メッセージを使う
144146
"lsp" - language server protocol エンコーディングを使う
147+
"dap" - debug adapter protocol エンコーディングを使う
145148
*channel-callback* *E921*
146149
"callback" メッセージ受信時に他のハンドラーで扱われない時に呼ばれます
147150
(例えば、ID が0の JSON メッセージ)。これはチャネルのハンドル
@@ -151,12 +154,13 @@ send を呼ぶたびに毎回コールバックを指定する代わりに、チ
151154
endfunc
152155
let channel = ch_open("localhost:8765", {"callback": "Handle"})
153156
<
154-
"mode" が "json", "js", "lsp" の時には、"msg" 引数は受信した
155-
メッセージの本文で、Vim の型に変換されています。
157+
"mode" が "json"、"js"、"lsp"、または "dap" のいずれかの場合、
158+
"msg" 引数は受信したメッセージの本文であり、Vim の型に変換され
159+
る。
156160
"mode" が "nl" の時には、"msg" 引数は NL を除く 1 つのメッセー
157-
ジです
161+
ジである
158162
"mode" が "raw" の時には、"msg" 引数はメッセージ全体を格納し
159-
た文字列です
163+
た文字列である
160164

161165
すべてのコールバック: |function()| を使用して、引数および/また
162166
は辞書にバインドします。または、"dict.function" という形式を使
@@ -537,16 +541,16 @@ ch_evalexpr({handle}, {expr} [, {options}]) *ch_evalexpr()*
537541
ンコードされる。この関数は生のチャネルでは使用できない。
538542
|channel-use| を参照。
539543
{handle} はチャネルもしくはチャネルを持つジョブであっても良い。
540-
"lsp" モードでチャネル使用時は、{expr}|Dict| でなければな
541-
らない
544+
"lsp" または "dap" モードでチャネル使用時は、{expr}|Dict|
545+
でなければならない
542546
*E917*
543547
{options} は辞書でなければならない。また "callback" のエントリ
544548
を持ってはならない。また個別のリクエストに対して "timeout" を
545549
持つ事ができる。
546550

547551
ch_evalexpr() は応答を待ち、式をデコードした物が返される。エ
548552
ラーもしくはタイムアウトの場合は空の |String|、あるいは "lsp"
549-
モードでチャネル使用時は空の |Dict| が返る。
553+
または "dap" モードでチャネル使用時は空の |Dict| が返る。
550554

551555
Note 応答を待っている間、Vimは他のメッセージを処理する。これが
552556
トラブルを引き起こさないことを確認する必要がある。
@@ -624,7 +628,7 @@ ch_info({handle}) *ch_info()*
624628
"err_io" "out", "null", "pipe", "file" または "buffer"
625629
"err_timeout" タイムアウト(ミリ秒)
626630
"in_status" "open" または "closed"
627-
"in_mode" "NL", "RAW", "JSON", "JS" または "LSP"
631+
"in_mode" "NL", "RAW", "JSON", "JS", "LSP" または "DAP"
628632
"in_io" "null", "pipe", "file" または "buffer"
629633
"in_timeout" タイムアウト(ミリ秒)
630634

@@ -733,14 +737,14 @@ ch_sendexpr({handle}, {expr} [, {options}]) *ch_sendexpr()*
733737
|channel-use| を参照。 *E912*
734738
{handle} はチャネルもしくはチャネルを持つジョブであっても良い。
735739
チャネルは開いていなければならない。
736-
"lsp" モードでチャネル使用時は、{expr}|Dict| でなければな
737-
らない
740+
"lsp" まただ "dap" モードでチャネル使用時は、{expr}|Dict|
741+
でなければならない
738742

739-
チャネルのモードが "lsp" の場合、辞書を返す。それ以外は空の文
740-
字列を返す{options} に "callback" の項目が存在する場合、リク
741-
エストメッセージのIDを含む辞書を返す。IDはLSPサーバーへキャン
742-
セルのリクエスト(必要な場合)を送るのに使うことができる。エラー
743-
のときは空の辞書を返す
743+
チャネルのモードが "lsp" または "dap" の場合、辞書を返す。それ
744+
以外は空の文字列を返す{options} に "callback" の項目が存在す
745+
る場合、リクエストメッセージの ID を含む辞書を返す。ID は LSP
746+
サーバーまたは DAP サーバーへキャンセルのリクエスト(必要な場合)
747+
を送るのに使うことができる。エラーのときは空の辞書を返す
744748

745749
{expr} に対して応答メッセージを受けないのであれば、{options}
746750
に "callback" 項目を指定しないこと。
@@ -1454,9 +1458,9 @@ Shift-CTRL-W を使用します)。ウィンドウを離れるとき挿入モー
14541458
startinsert
14551459
14561460
==============================================================================
1457-
15. Language Server Protocol *language-server-protocol*
1461+
15. 言語サーバープロトコル *language-server-protocol*
14581462

1459-
language server protocol の仕様は以下にあります:
1463+
言語サーバープロトコルの仕様は以下にあります:
14601464

14611465
https://microsoft.github.io/language-server-protocol/specification
14621466

@@ -1603,5 +1607,31 @@ LSP 通知メッセージは以下のフォーマット(Vim Dict で表現)を
16031607
"params": <list|dict>
16041608
}
16051609
1606-
<
1610+
==============================================================================
1611+
16. デバッグアダプタープロトコル *debug-adapter-protocol*
1612+
1613+
デバッグアダプタープロトコルは言語サーバープロトコルと非常に似ているが、主な違
1614+
いは JSON-RPC 形式を使用しないことである。仕様はここで確認できる:
1615+
1616+
https://microsoft.github.io/debug-adapter-protocol/specification
1617+
1618+
このプロトコルは、LSP プロトコルと同じヘッダー形式を使用する。
1619+
1620+
Vim |Dict| 内の DAP 要求/通知メッセージを JSON メッセージにエンコードして送信
1621+
し、DAP JSON 応答/通知メッセージを Vim |Dict| に受信してデコードするに
1622+
は、|channel-mode| を "dap" に設定してデバッグアダプターに接続する。
1623+
1624+
|channel-mode| が "dap" に設定されているチャンネルで受信されたメッセージの場
1625+
合、Vim は HTTP ヘッダーを処理し、JSON ペイロードを Vim の |Dict| 型にデコード
1626+
する。|ch_evalexpr()| または |ch_sendexpr()| 関数を使用してチャンネルでメッセー
1627+
ジを送信する場合、Vim は HTTP ヘッダーを追加し、Vim 式を JSON にエンコードす
1628+
る。
1629+
1630+
Vim は JSON DAP メッセージに "seq" フィールドを自動的に追加し、レスポンスの
1631+
"request_seq" フィールドも管理する。ただし、"type" フィールドは追加されないた
1632+
め、|Dict| で手動で指定する必要がある。
1633+
1634+
それ以外の場合、動作は Vim が "lsp" チャネルモード |language-server-protocol|
1635+
を処理する方法と同じである。
1636+
16071637
vim:tw=78:ts=8:noet:ft=help:norl:

en/channel.txt

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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|
2626
13. Controlling a job |job-control|
2727
14. Using a prompt buffer |prompt-buffer|
2828
15. 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
5657
JSON JSON encoding |json_encode()|
5758
JS JavaScript style JSON-like encoding |js_encode()|
5859
LSP Language Server Protocol encoding |language-server-protocol|
60+
DAP Debug Adapter Protocol encoding |debug-adapter-protocol|
5961

6062
Common 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

Comments
 (0)