Home Explore Blog CI



neovim

16th chunk of `runtime/doc/vimfn.txt`
223ba7aaf0648c78be20afbcbdc75f04efd7907b3a5507230000000100000fac
 "dictionary"	     Dictionary |i_CTRL-X_CTRL-K|
		   "thesaurus"	     Thesaurus |i_CTRL-X_CTRL-T|
		   "cmdline"	     Vim Command line |i_CTRL-X_CTRL-V|
		   "function"	     User defined completion |i_CTRL-X_CTRL-U|
		   "omni"	     Omni completion |i_CTRL-X_CTRL-O|
		   "spell"	     Spelling suggestions |i_CTRL-X_s|
		   "eval"	     |complete()| completion
		   "register"	     Words from registers |i_CTRL-X_CTRL-R|
		   "unknown"	     Other internal modes

		If the optional {what} list argument is supplied, then only
		the items listed in {what} are returned.  Unsupported items in
		{what} are silently ignored.

		To get the position and size of the popup menu, see
		|pum_getpos()|. It's also available in |v:event| during the
		|CompleteChanged| event.

		Returns an empty |Dictionary| on error.

		Examples: >vim
			" Get all items
			call complete_info()
			" Get only 'mode'
			call complete_info(['mode'])
			" Get only 'mode' and 'pum_visible'
			call complete_info(['mode', 'pum_visible'])
<

                Parameters: ~
                  • {what} (`any[]?`)

                Return: ~
                  (`table`)

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: >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
		  endfunc
		  inoremap <Tab> <Cmd>call CustomComplete()<CR>
<

                Parameters: ~
                  • {lnum} (`integer?`)
                  • {col} (`integer?`)

                Return: ~
                  (`table`)

confirm({msg} [, {choices} [, {default} [, {type}]]])                *confirm()*
		confirm() offers the user a dialog, from which a choice can be
		made.  It returns the number of the choice.  For the first
		choice this is 1.

		{msg} is displayed in a dialog with {choices} as the
		alternatives.  When {choices} is missing or empty, "&OK" is
		used (and translated).
		{msg} is a String, use '\n' to include a newline.  Only on
		some systems the string is wrapped when it doesn't fit.

		{choices} is a String, with the individual choices separated
		by '\n', e.g. >vim
			confirm("Save changes?", "&Yes\n&No\n&Cancel")
<		The letter after the '&' is the shortcut key for that choice.
		Thus you can type 'c' to select "Cancel".  The shortcut does
		not need to be the first letter: >vim
			confirm("file has been modified", "&Save\nSave &All")
<		For the console, the first letter of each choice is used as
		the default shortcut key.  Case is ignored.

		The optional {type} String argument gives the type of dialog.
		It can be one of these values: "Error", "Question", "Info",
		"Warning" or "Generic".  Only the first character is relevant.

Title: Vimscript Complete Function Details and Confirm Function
Summary
This section provides details about the complete_info() function, which returns a dictionary containing information about Insert mode completion and lists available completion modes, like dictionary, thesaurus, cmdline, function, omni, spell, eval, and register. It also covers the complete_match() function, which searches backward and returns a list of matches based on the 'isexpand' option. Finally, it introduces the confirm() function, which displays a dialog box to the user with choices and returns the number of the chosen option.