before the cursor is used for suggestions, even though it isn't badly spelled.
NOTE: CTRL-S suspends display in many Unix terminals. Use 's' instead. Type
CTRL-Q to resume displaying.
*i_CTRL-X_CTRL-S* *i_CTRL-X_s*
CTRL-X CTRL-S or
CTRL-X s Locate the word in front of the cursor and find the
first spell suggestion for it.
CTRL-S or
CTRL-N Use the next suggestion. This replaces the previous
one. Note that you can't use 's' here.
CTRL-P Use the previous suggestion. This replaces the
previous one.
Completing keywords from different sources *compl-generic*
*i_CTRL-N*
CTRL-N Find next match for words that start with the
keyword in front of the cursor, looking in places
specified with the 'complete' option. The found
keyword is inserted in front of the cursor.
*i_CTRL-P*
CTRL-P Find previous match for words that start with the
keyword in front of the cursor, looking in places
specified with the 'complete' option. The found
keyword is inserted in front of the cursor.
CTRL-N Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
CTRL-P Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
CTRL-X CTRL-N or
CTRL-X CTRL-P Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
copy the words following the previous expansion in
other contexts unless a double CTRL-X is used.
Stop completion *compl-stop*
*i_CTRL-X_CTRL-Z*
CTRL-X CTRL-Z Stop completion without changing the text.
AUTO-COMPLETION *compl-autocomplete*
To get LSP-driven auto-completion, see |lsp-completion|. To get basic
auto-completion without installing plugins or LSP, try this: >lua
local triggers = {'.'}
vim.api.nvim_create_autocmd('InsertCharPre', {
buffer = vim.api.nvim_get_current_buf(),
callback = function()
if vim.fn.pumvisible() == 1 or vim.fn.state('m') == 'm' then
return
end
local char = vim.v.char
if vim.list_contains(triggers, char) then
local key = vim.keycode('<C-x><C-n>')
vim.api.nvim_feedkeys(key, 'm', false)
end
end
})
<
FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
This applies to 'completefunc', 'thesaurusfunc' and 'omnifunc'.
The function is called in two different ways:
- First the function is called to find the start of the text to be completed.
- Later the function is called to actually find the matches.
On the first invocation the arguments are:
a:findstart 1
a:base empty
The function must return the column where the completion starts. It must be a
number between zero and the cursor column "col('.')". This involves looking
at the characters just before the cursor and including those characters that
could be part of the completed item. The text between this column and the
cursor column will be replaced with the matches. If the returned value is
larger than the cursor column, the 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