2023-05-20 12:44:21 +01:00
|
|
|
local config = function()
|
|
|
|
local cmp = require "cmp"
|
|
|
|
local luasnip = require "luasnip"
|
|
|
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
|
|
|
|
|
|
|
cmp.setup {
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert {
|
|
|
|
["<C-u>"] = cmp.mapping.scroll_docs(-4), -- Up
|
|
|
|
["<C-d>"] = cmp.mapping.scroll_docs(4), -- Down
|
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
|
|
["<CR>"] = cmp.mapping.confirm {
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
select = true,
|
|
|
|
},
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
elseif luasnip.jumpable(-1) then
|
|
|
|
luasnip.jump(-1)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
},
|
2023-06-10 08:29:21 +01:00
|
|
|
sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "neorg" } },
|
2023-05-20 12:44:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
"hrsh7th/nvim-cmp",
|
2023-05-31 16:47:30 +01:00
|
|
|
cond = not vim.g.vscode,
|
2023-06-10 08:29:21 +01:00
|
|
|
event = "InsertEnter",
|
2023-05-20 12:44:21 +01:00
|
|
|
dependencies = {
|
|
|
|
"hrsh7th/cmp-nvim-lsp",
|
2023-06-11 08:41:00 +01:00
|
|
|
{
|
|
|
|
"windwp/nvim-autopairs",
|
|
|
|
cond = not vim.g.vscode,
|
|
|
|
lazy = true,
|
|
|
|
dependencies = {
|
|
|
|
"nvim-treesitter/nvim-treesitter",
|
|
|
|
"hrsh7th/nvim-cmp",
|
|
|
|
},
|
|
|
|
config = true,
|
|
|
|
opts = {
|
|
|
|
disable_in_macro = true,
|
|
|
|
disable_in_visualblock = true,
|
|
|
|
check_ts = true,
|
|
|
|
},
|
|
|
|
},
|
2023-05-20 12:44:21 +01:00
|
|
|
"saadparwaiz1/cmp_luasnip",
|
|
|
|
"L3MON4D3/LuaSnip",
|
|
|
|
},
|
|
|
|
config = config,
|
|
|
|
}
|