From 7adae65c9f5508f3d97d6d7ddb2d525515b60708 Mon Sep 17 00:00:00 2001 From: h-east Date: Wed, 30 Apr 2025 20:55:49 +0900 Subject: [PATCH 1/3] Update builtin.{txt,jax} --- doc/builtin.jax | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- en/builtin.txt | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 152 insertions(+), 6 deletions(-) diff --git a/doc/builtin.jax b/doc/builtin.jax index 4bc870cac..8c72d2548 100644 --- a/doc/builtin.jax +++ b/doc/builtin.jax @@ -1,4 +1,4 @@ -*builtin.txt* For Vim バージョン 9.1. Last change: 2025 Apr 18 +*builtin.txt* For Vim バージョン 9.1. Last change: 2025 Apr 27 VIMリファレンスマニュアル by Bram Moolenaar @@ -142,12 +142,14 @@ charidx({string}, {idx} [, {countcc} [, {utf16}]]) chdir({dir}) 文字列 現在の作業ディレクトリを変更する cindent({lnum}) 数値 {lnum}行目のCインデント量 clearmatches([{win}]) なし 全マッチをクリアする +cmdcomplete_info() 辞書 現在のコマンドライン補完の情報を取得 col({expr} [, {winid}]) 数値 カーソルかマークのカラムバイトインデッ クス complete({startcol}, {matches}) なし 挿入モード補完を設定する complete_add({expr}) 数値 補完候補を追加する complete_check() 数値 補完中に押されたキーをチェックする complete_info([{what}]) 辞書 現在の補完情報を取得 +complete_match([{lnum}, {col}]) リスト 補完桁とトリガーテキストを取得 confirm({msg} [, {choices} [, {default} [, {type}]]]) 数値 ユーザーへの選択肢と番号 copy({expr}) 任意 {expr}の浅いコピーを作る @@ -1881,6 +1883,30 @@ clearmatches([{win}]) *clearmatches()* 戻り値の型: |Number| +cmdcomplete_info() *cmdcomplete_info()* + コマンドライン補完に関する情報を含む |Dictionary| を返す。 + |cmdline-completion| を参照。 + 項目は以下: + cmdline_orig 補完が始まる前の元のコマンドライン文字列。 + pum_visible ポップアップメニューが表示されている場合は + |TRUE|。 + |pumvisible()| を参照。 + matches すべての補完候補のリスト。各項目は文字列であ + る。 + selected 選択された項目のインデックス。最初のインデック + スは 0 である。項目が選択されていない場合、イ + ンデックスは-1 になる (入力されたテキストのみ、 + または キーまたは キーを使用した場 + 合は、項目が選択されていない状態で最後に補完さ + れた項目が表示される) + + 補完が試行されなかった場合、候補が 1 つしかなくそれが完全に補 + 完された場合、またはエラーが発生した場合は、空の |Dictionary| + を返す。 + + 戻り値の型: dict + + col({expr} [, {winid}]) *col()* 戻り値は数値で、{expr} で与えられる位置の桁番号(バイトインデッ クス)。 @@ -2050,6 +2076,50 @@ complete_info([{what}]) *complete_info()* < 戻り値の型: dict +complete_match([{lnum}, {col}]) *complete_match()* + 指定された位置から後方に検索し、'isexpand' オプションに従って + マッチした文字列のリストを返す。引数が指定されていない場合は、 + 現在のカーソル位置を使用する。 + + 各マッチは、[startcol, trigger_text] を含むリストとして表され + る: + - startcol: 補完を開始する桁位置。トリガー位置が見つからない場 + 合は -1 を返す。複数文字のトリガーの場合は、最初の文字の桁を + 返す。 + - trigger_text: 'isexpand' からのマッチするトリガー文字列、ま + たはマッチするものが見つからなかったか、デフォルトの + 'iskeyword' パターンを使用している場合は空の文字列。 + + 'isexpand' が空の場合、'iskeyword' のパターン "\k\+$" を使用し + て現在のキーワードの開始位置を検索する。 + + 例: > + set isexpand=.,->,/,/*,abc + func CustomComplete() + let res = complete_match() + if res->len() == 0 | return | endif + let [col, trigger] = res[0] + let items = [] + if trigger == '/*' + let items = ['/** */'] + elseif trigger == '/' + let items = ['/*! */', '// TODO:', '// fixme:'] + elseif trigger == '.' + let items = ['length()'] + elseif trigger =~ '^\->' + let items = ['map()', 'reduce()'] + elseif trigger =~ '^\abc' + let items = ['def', 'ghk'] + endif + if items->len() > 0 + let startcol = trigger =~ '^/' ? col : col + len(trigger) + call complete(startcol, items) + endif + endfunc + inoremap call CustomComplete() +< + 戻り値の型: list> + *confirm()* confirm({msg} [, {choices} [, {default} [, {type}]]]) confirm()はユーザーに選択させるためのダイアログを提供する。戻 @@ -3244,7 +3314,8 @@ finddir({name} [, {path} [, {count}]]) *finddir()* |method| としても使用できる: > GetName()->finddir() < - 戻り値の型: |String| + 戻り値の型: {count} が負の場合は list、それ以外の場合 + は |String| 。 findfile({name} [, {path} [, {count}]]) *findfile()* @@ -3258,7 +3329,8 @@ findfile({name} [, {path} [, {count}]]) *findfile()* |method| としても使用できる: > GetName()->findfile() < - 戻り値の型: |String| + 戻り値の型: {count} が負の場合は list、それ以外の場合 + は |String| 。 flatten({list} [, {maxdepth}]) *flatten()* @@ -4229,6 +4301,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* file ファイルおよびディレクトリ名 file_in_path |'path'|のファイルおよびディレクトリ名 filetype ファイルタイプ名 |'filetype'| + filetypecmd |:filetype| サブオプション function 関数名 help ヘルプ項目 highlight ハイライトグループ diff --git a/en/builtin.txt b/en/builtin.txt index b69f6b463..55a0731a8 100644 --- a/en/builtin.txt +++ b/en/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2025 Apr 18 +*builtin.txt* For Vim version 9.1. Last change: 2025 Apr 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -129,11 +129,14 @@ charidx({string}, {idx} [, {countcc} [, {utf16}]]) chdir({dir}) String change current working directory cindent({lnum}) Number C indent for line {lnum} clearmatches([{win}]) none clear all matches +cmdcomplete_info() Dict get current cmdline completion + information col({expr} [, {winid}]) Number column byte index of cursor or mark complete({startcol}, {matches}) none set Insert mode completion complete_add({expr}) Number add completion match complete_check() Number check for key typed during completion complete_info([{what}]) Dict get current completion information +complete_match([{lnum}, {col}]) List get completion column and trigger text confirm({msg} [, {choices} [, {default} [, {type}]]]) Number number of choice picked by user copy({expr}) any make a shallow copy of {expr} @@ -1832,6 +1835,29 @@ clearmatches([{win}]) *clearmatches()* Return type: |Number| +cmdcomplete_info() *cmdcomplete_info()* + Returns a |Dictionary| with information about cmdline + completion. See |cmdline-completion|. + The items are: + cmdline_orig The original command-line string before + completion began. + pum_visible |TRUE| if popup menu is visible. + See |pumvisible()|. + matches List of all completion candidates. Each item + is a string. + selected Selected item index. First index is zero. + Index is -1 if no item is selected (showing + typed text only, or the last completion after + no item is selected when using the or + keys) + + Returns an empty |Dictionary| if no completion was attempted, + if there was only one candidate and it was fully completed, or + if an error occurred. + + Return type: dict + + col({expr} [, {winid}]) *col()* The result is a Number, which is the byte index of the column position given with {expr}. @@ -2007,6 +2033,50 @@ complete_info([{what}]) *complete_info()* < Return type: dict +complete_match([{lnum}, {col}]) *complete_match()* + Searches backward from the given position and returns a List + of matches according to the 'isexpand' option. When no + arguments are provided, uses the current cursor position. + + Each match is represented as a List containing + [startcol, trigger_text] where: + - startcol: column position where completion should start, + or -1 if no trigger position is found. For multi-character + triggers, returns the column of the first character. + - trigger_text: the matching trigger string from 'isexpand', + or empty string if no match was found or when using the + default 'iskeyword' pattern. + + When 'isexpand' is empty, uses the 'iskeyword' pattern + "\k\+$" to find the start of the current keyword. + + Examples: > + set isexpand=.,->,/,/*,abc + func CustomComplete() + let res = complete_match() + if res->len() == 0 | return | endif + let [col, trigger] = res[0] + let items = [] + if trigger == '/*' + let items = ['/** */'] + elseif trigger == '/' + let items = ['/*! */', '// TODO:', '// fixme:'] + elseif trigger == '.' + let items = ['length()'] + elseif trigger =~ '^\->' + let items = ['map()', 'reduce()'] + elseif trigger =~ '^\abc' + let items = ['def', 'ghk'] + endif + if items->len() > 0 + let startcol = trigger =~ '^/' ? col : col + len(trigger) + call complete(startcol, items) + endif + endfunc + inoremap call CustomComplete() +< + Return type: list> + *confirm()* confirm({msg} [, {choices} [, {default} [, {type}]]]) confirm() offers the user a dialog, from which a choice can be @@ -3235,7 +3305,8 @@ finddir({name} [, {path} [, {count}]]) *finddir()* Can also be used as a |method|: > GetName()->finddir() < - Return type: |String| + Return type: list if {count} is negative, |String| + otherwise findfile({name} [, {path} [, {count}]]) *findfile()* @@ -3249,7 +3320,8 @@ findfile({name} [, {path} [, {count}]]) *findfile()* Can also be used as a |method|: > GetName()->findfile() < - Return type: |String| + Return type: list if {count} is negative, |String| + otherwise flatten({list} [, {maxdepth}]) *flatten()* @@ -4243,6 +4315,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* file file and directory names file_in_path file and directory names in |'path'| filetype filetype names |'filetype'| + filetypecmd |:filetype| suboptions function function name help help subjects highlight highlight groups From fd081518a446f79af1c699b84eda99553b7d1adc Mon Sep 17 00:00:00 2001 From: h-east Date: Tue, 6 May 2025 22:14:59 +0900 Subject: [PATCH 2/3] fix by review --- doc/builtin.jax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/builtin.jax b/doc/builtin.jax index 8c72d2548..5c6601e17 100644 --- a/doc/builtin.jax +++ b/doc/builtin.jax @@ -149,7 +149,7 @@ complete({startcol}, {matches}) なし 挿入モード補完を設定する complete_add({expr}) 数値 補完候補を追加する complete_check() 数値 補完中に押されたキーをチェックする complete_info([{what}]) 辞書 現在の補完情報を取得 -complete_match([{lnum}, {col}]) リスト 補完桁とトリガーテキストを取得 +complete_match([{lnum}, {col}]) リスト 補完のカラムとトリガー文字列を取得 confirm({msg} [, {choices} [, {default} [, {type}]]]) 数値 ユーザーへの選択肢と番号 copy({expr}) 任意 {expr}の浅いコピーを作る From 57fbd4c2eb88b0e133fe83e6fbce4c6526104036 Mon Sep 17 00:00:00 2001 From: h_east Date: Sat, 10 May 2025 03:56:08 +0900 Subject: [PATCH 3/3] Update doc/builtin.jax Co-authored-by: mityu --- doc/builtin.jax | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/builtin.jax b/doc/builtin.jax index 5c6601e17..b01189a0e 100644 --- a/doc/builtin.jax +++ b/doc/builtin.jax @@ -1895,10 +1895,10 @@ cmdcomplete_info() *cmdcomplete_info()* る。 selected 選択された項目のインデックス。最初のインデック スは 0 である。項目が選択されていない場合、イ - ンデックスは-1 になる (入力されたテキストのみ、 - または キーまたは キーを使用した場 - 合は、項目が選択されていない状態で最後に補完さ - れた項目が表示される) + ンデックスは -1 になる (入力されたテキストの + み、または キーまたは キーを使用し + た場合は、項目が選択されていない状態で最後に補 + 完された項目が表示される) 補完が試行されなかった場合、候補が 1 つしかなくそれが完全に補 完された場合、またはエラーが発生した場合は、空の |Dictionary|