diff --git a/doc/wayland.jax b/doc/wayland.jax index 966a8aeff..42ccecb47 100644 --- a/doc/wayland.jax +++ b/doc/wayland.jax @@ -1,4 +1,4 @@ -*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Feb 14 +*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Apr 20 VIM リファレンスマニュアル by Bram Moolenaar @@ -50,15 +50,13 @@ Vim は Wayland コンポジタとの通信に失敗した。これは Wayland Vim は、現在の Wayland セレクションにアクセスするための wlr-data-control-unstable-v1 プロトコルと ext-data-control-v1 プロトコルをサ -ポートしている。これらは最適なシナリオのプロトコルである。 -|wayland-focus-steal| を参照。この場合のセレクションは基本的に "clipboard" を -指す。Wayland コンポジタがこれらのプロトコルをサポートしているかどうかを確認す -るには、wayland-info コマンドを実行する。このコマンドは、あなたのシステムでは +ポートしている。この場合のセレクションは基本的に "clipboard" を指す。Wayland +コンポジタがこれらのプロトコルをサポートしているかどうかを確認するには、 +wayland-info コマンドを実行する。このコマンドは、あなたのシステムでは libwayland にバンドルされているはずである: > wayland-info | grep -E '(ext_data_control|zwlr_data_control)' + wayland-info | grep -E '(ext_data_control|zwlr_data_control)' +"zwlr_data_control_manager_v1" の "version:" エントリが "2" 以上であれば、プラ +イマリ選択がサポートされる。また、"ext_data_control_manager_v1" も取得できた場 +合は、Vim は代わりにそのプロトコルを使用する。このプロトコルにはプライマリ選択 +のサポートが組み込まれている。 + +Wayland コンポジタが wlr-data-control-v1 または ext-data-control-v1 プロトコル +をサポートしていない場合、Vim は Wayland プロトコルを介してクリップボードに直 +接アクセスできない。代わりに、ユーザー定義の |clipboard-providers| を介して +wl-clipboard などの外部ツールを使用できる。 + +例: `wl-copy` と `wl-paste` を実行するプロバイダを定義する: >vim9 + + vim9script + + def Available(): bool + return executable('wl-copy') && executable('wl-paste') + enddef + + def Copy(reg: string, type: string, str: list) + var args = "wl-copy" + + if reg == "*" + args ..= " -p" + endif + + system(args, str) + enddef + + def Paste(reg: string): tuple> + var args = "wl-paste --type text/plain;charset=utf-8" + + if reg == "*" + args ..= " -p" + endif + + return ("", systemlist(args)) + enddef + + v:clipproviders["wl_clipboard"] = { + available: Available, + copy: { + "+": Copy, + "*": Copy + }, + paste: { + "+": Paste, + "*": Paste + } + } + + set clipmethod=wl_clipboard + + +これは、wl-clipboard パッケージがインストールされていることを前提としている +(https://github.com/bugaevc/wl-clipboard). vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/en/wayland.txt b/en/wayland.txt index 8d352bde9..af491064d 100644 --- a/en/wayland.txt +++ b/en/wayland.txt @@ -1,4 +1,4 @@ -*wayland.txt* For Vim version 9.2. Last change: 2026 Feb 14 +*wayland.txt* For Vim version 9.2. Last change: 2026 Apr 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -54,15 +54,12 @@ try connecting again. 2. Wayland Selections *wayland-selections* Vim supports the wlr-data-control-unstable-v1 and ext-data-control-v1 -protocols, for accessing the current Wayland selection. These are the best -case scenario protocols, see |wayland-focus-steal|. Selection in this case +protocols, for accessing the current Wayland selection. Selection in this case essentially means the "clipboard." You can check if your Wayland compositor supports either of these protocols by running the wayland-info command, which should be bundled with libwayland on your system: > wayland-info | grep -E '(ext_data_control|zwlr_data_control)' + wayland-info | grep -E '(ext_data_control|zwlr_data_control)' +If the "version:" entry for "zwlr_data_control_manager_v1" is "2" or greater, +then primary selection is supported. If you also get +"ext_data_control_manager_v1", then Vim will use that protocol instead, which +has primary selection support builtin into it. + +If your Wayland compositor does not support the wlr-data-control-v1 or the +ext-data-control-v1 protocol, Vim cannot access the clipboard directly through +the Wayland protocol. External tools such as wl-clipboard can be used instead +via a user-defined |clipboard-providers|. + +Example: define a provider that shells out to `wl-copy` and `wl-paste`: >vim9 + + vim9script + + def Available(): bool + return executable('wl-copy') && executable('wl-paste') + enddef + + def Copy(reg: string, type: string, str: list) + var args = "wl-copy" + + if reg == "*" + args ..= " -p" + endif + + system(args, str) + enddef + + def Paste(reg: string): tuple> + var args = "wl-paste --type text/plain;charset=utf-8" + + if reg == "*" + args ..= " -p" + endif + + return ("", systemlist(args)) + enddef + + v:clipproviders["wl_clipboard"] = { + available: Available, + copy: { + "+": Copy, + "*": Copy + }, + paste: { + "+": Paste, + "*": Paste + } + } + + set clipmethod=wl_clipboard + + +This relies on the wl-clipboard package being installed +(https://github.com/bugaevc/wl-clipboard). vim:tw=78:ts=8:noet:ft=help:norl