69 lines
2.0 KiB
Lua
69 lines
2.0 KiB
Lua
return {
|
|
{ "L3MON4D3/LuaSnip", event = "InsertEnter" },
|
|
{ "rafamadriz/friendly-snippets", event = "InsertEnter" },
|
|
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
event = "InsertEnter",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
"L3MON4D3/LuaSnip",
|
|
"onsails/lspkind.nvim",
|
|
"windwp/nvim-autopairs",
|
|
"rafamadriz/friendly-snippets",
|
|
},
|
|
config = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
local lspkind = require("lspkind")
|
|
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args) luasnip.lsp_expand(args.body) end,
|
|
},
|
|
formatting = {
|
|
format = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 }),
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<CR>"] = cmp.mapping.confirm({ 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" }),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "path" },
|
|
{ name = "buffer" },
|
|
}),
|
|
})
|
|
|
|
-- autopairs integration
|
|
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
|
end,
|
|
},
|
|
}
|
|
|