Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.complete

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.complete
import { fn } from "https://deno.land/x/ddc_vim@v3.8.0/deps.ts";
const { complete } = fn;

Set the matches for Insert mode completion. Can only be used in Insert mode. You need to use a mapping with CTRL-R = (see i_CTRL-R). It does not work after CTRL-O or with an expression mapping. {startcol} is the byte offset in the line where the completed text start. The text up to the cursor is the original text that will be replaced by the matches. Use col('.') for an empty string. "col('.') - 1" will replace one character by a match. {matches} must be a List. Each List item is one match. See complete-items for the kind of items that are possible. "longest" in 'completeopt' is ignored. Note that the after calling this function you need to avoid inserting anything that would cause completion to stop. The match can be selected with CTRL-N and CTRL-P as usual with Insert mode completion. The popup menu will appear if specified, see ins-completion-menu. Example:

inoremap <F5> <C-R>=ListMonths()<CR>

func! ListMonths()
  call complete(col('.'), ['January', 'February', 'March',
        \ 'April', 'May', 'June', 'July', 'August', 'September',
        \ 'October', 'November', 'December'])
  return ''
endfunc

This isn't very useful, but it shows how it works. Note that an empty string is returned to avoid a zero being inserted.

Can also be used as a method, the base is passed as the second argument:

GetMatches()->complete(col('.'))

Parameters

denops: Denops
startcol: unknown
matches: unknown

Returns

Promise<void>