cmp
layer
#
The cmp
layer is a dependency for other layers providing a completion engine
(namely, nvim-cmp
).
Bindings #
In insert mode, with the suggestions list open:
<C-d>
: when selecting a suggestion, scrolls the documentation up;<C-f>
: when selecting a suggestion, scrolls the documentation down;<C-space>
: accepts suggestions;<C-e>
: closes suggestions list;<CR>
: accepts the selected suggestion;<Tab>
: selects the next item in the list;<S-Tab>
: selects the previous item in the list.
Bindings can be customized via the configuration.
Configuration #
buffer
(defaultfalse
): whether autocomplete from the buffer or not;lsp
(defaulttrue
): whether autocomplete from the LSP suggestions;lspkind
(defaulttrue
): whether autocomplete from LSP symbols à-la-IntelliSense;mappings
(see Bindings for default): a table whose keys are binds as strings (e.g.'<C-d>
) and values are handlers, much like thecmp.mapping.preset.insert
method innvim-cmp
;config
(default{ experimental = { ghost_text = true } }
) configuration to be passed tonvim-cmp
.
Examples #
-- path/of/your/vim/config/init.lua
require("visimp")({
cmp = {
buffer = true -- autocomplete from the buffer
config = {
experimental = {
ghost_text = false -- disable exprimental ghost text
},
},
},
})
Layer-specific API #
Other layers may interact with cmp
via the following methods.
add_source(source)
#
Adds a new completion source, as defined in cmp.config.source. The complete list is available in the wiki.
-- adds cmp-git for git-related completion
local snippet = require('visimp.loader').get('snippet')
cmp.add_source({ name = 'git' })
require('cmp_git').setup()
set_snippet(snippet)
#
Sets the snippet engine to be used, as specified in the docs
local snippet = require('visimp.loader').get('snippet')
snippet.set_snippet {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end
}
Documentation #
The full documentation for the plugin is available here.