69 lines
1.6 KiB
Lua
69 lines
1.6 KiB
Lua
return {
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
{
|
|
"L3MON4D3/LuaSnip",
|
|
lazy = true,
|
|
version = "v2.*",
|
|
build = "make install_jsregexp",
|
|
opts = {
|
|
history = true,
|
|
delete_check_events = "TextChanged",
|
|
},
|
|
dependencies = { "rafamadriz/friendly-snippets" },
|
|
config = function()
|
|
require("plugins.snippets")
|
|
end,
|
|
},
|
|
},
|
|
config = function()
|
|
local cmp = require("cmp")
|
|
local source_mapping = {
|
|
buffer = "[Buffer]",
|
|
nvim_lsp = "[LSP]",
|
|
nvim_lua = "[Lua]",
|
|
path = "[Path]",
|
|
}
|
|
cmp.setup({
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if require("luasnip").expand_or_jumpable() then
|
|
require("luasnip").expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if require("luasnip").jumpable(-1) then
|
|
require("luasnip").jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
}),
|
|
snippet = {
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
end,
|
|
},
|
|
formatting = {
|
|
format = function(entry, vim_item)
|
|
vim_item.menu = source_mapping[entry.source.name] or "[Unknown]"
|
|
return vim_item
|
|
end,
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lsp", priority = 1000 },
|
|
{ name = "luasnip", priority = 750 },
|
|
{ name = "path", priority = 500 },
|
|
}, {
|
|
{ name = "buffer" },
|
|
}),
|
|
})
|
|
end,
|
|
}
|