mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
vim-patch:ffc89e4 runtime(doc): clarify complete_match() and 'isexpand' option
clarify complete_match() documentation to better explain its backward
search behavior, argument handling, and return value format and add an
example of isexpand
closes: https://github.com/vim/vim/pull/17212
ffc89e47d0
This commit is contained in:
@@ -1481,8 +1481,11 @@ M.funcs = {
|
||||
args = { 0, 2 },
|
||||
base = 0,
|
||||
desc = [=[
|
||||
Returns a List of matches found according to the 'isexpand'
|
||||
option. Each match is represented as a List containing
|
||||
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
|
||||
@@ -1494,39 +1497,34 @@ M.funcs = {
|
||||
When 'isexpand' is empty, uses the 'iskeyword' pattern
|
||||
"\k\+$" to find the start of the current keyword.
|
||||
|
||||
When no arguments are provided, uses the current cursor
|
||||
position.
|
||||
|
||||
Examples: >
|
||||
Examples: >vim
|
||||
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
|
||||
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 <Tab> <Cmd>call CustomComplete()<CR>
|
||||
<
|
||||
|
||||
Return type: list<list<any>>
|
||||
<
|
||||
]=],
|
||||
name = 'complete_match',
|
||||
params = { { 'lnum', 'integer?' }, { 'col', 'integer?' } },
|
||||
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
|
||||
returns = 'table',
|
||||
signature = 'complete_match([{lnum}, {col}])',
|
||||
},
|
||||
|
Reference in New Issue
Block a user