mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-23 10:27:34 +00:00
57 lines
1.6 KiB
Lua
57 lines
1.6 KiB
Lua
local M = {}
|
|
|
|
function M.config_cmp()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
cmp.setup({
|
|
completion = {
|
|
completeopt = "menuone,noinsert",
|
|
autocomplete = false,
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
end,
|
|
},
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "buffer" },
|
|
{ name = "spell" },
|
|
},
|
|
mapping = {
|
|
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
|
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end),
|
|
["<C-Space>"] = cmp.mapping(function()
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
else
|
|
cmp.complete()
|
|
end
|
|
end, { "i", "c" }),
|
|
["<C-e>"] = cmp.mapping({
|
|
i = cmp.mapping.abort(),
|
|
c = cmp.mapping.close(),
|
|
}),
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
},
|
|
})
|
|
|
|
-- Add a plug mapping to use in C-Space binding
|
|
vim.api.nvim_set_keymap(
|
|
"i",
|
|
"<Plug>(cmp_complete)",
|
|
"<cmd>lua require('cmp').complete()<CR>",
|
|
{ silent = true, noremap = true }
|
|
)
|
|
end
|
|
|
|
return M
|