Home Explore Blog CI



neovim

17th chunk of `runtime/doc/insert.txt`
57d52fe3301111b313e6d49aed91acdfe92da682c4585c820000000100000fa0
 cursor column is used.

Negative return values:
   -2	To cancel silently and stay in completion mode.
   -3	To cancel silently and leave completion mode.
   Another negative value: completion starts at the cursor column

On the second invocation the arguments are:
   a:findstart  0
   a:base	the text with which matches should match; the text that was
		located in the first call (can be empty)

The function must return a List with the matching words.  These matches
usually include the "a:base" text.  When there are no matches return an empty
List.  Note that the cursor may have moved since the first invocation, the
text may have been changed.

In order to return more information than the matching words, return a Dict
that contains the List.  The Dict can have these items:
	words		The List of matching words (mandatory).
	refresh		A string to control re-invocation of the function
			(optional).
			The only value currently recognized is "always", the
			effect is that the function is called whenever the
			leading text is changed.
Other items are ignored.

For acting upon end of completion, see the |CompleteDonePre| and
|CompleteDone| autocommand event.

For example, the function can contain this: >
	let matches = ... list of words ...
	return {'words': matches, 'refresh': 'always'}
<
If looking for matches is time-consuming, |complete_check()| may be used to
maintain responsiveness.

						*complete-items*
Each list item can either be a string or a Dictionary.  When it is a string it
is used as the completion.  When it is a Dictionary it can contain these
items:
	word		the text that will be inserted, mandatory
	abbr		abbreviation of "word"; when not empty it is used in
			the menu instead of "word"
	menu		extra text for the popup menu, displayed after "word"
			or "abbr"
	info		more information about the item, can be displayed in a
			preview window
	kind		single letter indicating the type of completion
	icase		when non-zero case is to be ignored when comparing
			items to be equal; when omitted zero is used, thus
			items that only differ in case are added
	equal		when non-zero, always treat this item to be equal when
			comparing. Which means, "equal=1" disables filtering
			of this item.
	dup		when non-zero this match will be added even when an
			item with the same word is already present.
	empty		when non-zero this match will be added even when it is
			an empty string
	user_data	custom data which is associated with the item and
			available in |v:completed_item|; it can be any type;
			defaults to an empty string
	abbr_hlgroup	an additional highlight group whose attributes are
			combined with |hl-PmenuSel| and |hl-Pmenu| or
			|hl-PmenuMatchSel| and |hl-PmenuMatch| highlight
			attributes in the popup menu to apply cterm and gui
			properties (with higher priority) like strikethrough
			to the completion items abbreviation
	kind_hlgroup	an additional highlight group specifically for setting
			the highlight attributes of the completion kind. When
			this field is present, it will override the
			|hl-PmenuKind| highlight group, allowing for the
			customization of ctermfg and guifg properties for the
			completion kind
	match		See "matches" in |complete_info()|.

All of these except "icase", "equal", "dup" and "empty" must be a string.  If
an item does not meet these requirements then an error message is given and
further items in the list are not used.  You can mix string and Dictionary
items in the returned list.

The "menu" item is used in the popup menu and may be truncated, thus it should
be relatively short.  The "info" item can be longer, it will  be displayed in
the preview window when "preview" appears in 'completeopt'.  The "info" item
will also remain displayed after the popup menu has been removed.  This is
useful for function arguments.  Use a single space for "info" to remove
existing text in the preview window.  The size of the preview window is three
lines, but 'previewheight' is used when it has a value of

Title: Completion Function Details: Return Values, Dict Items, and List Items
Summary
This section details the return values of completion functions, including negative values for cancellation. It describes the use of a Dictionary to return more information than just matching words, including 'words', 'refresh' options. It provides the details of list items of matching words, which can be strings or Dictionaries, covering various attributes such as 'word', 'abbr', 'menu', 'info', 'kind', 'icase', 'equal', 'dup', 'empty', 'user_data', 'abbr_hlgroup', 'kind_hlgroup', and 'match' and explaining their usage in the completion process.