Files
L-nvim-conf/lua/plugins/completions.lua
Johan 36024d663c new
2025-11-07 00:59:34 +00:00

82 lines
1.5 KiB
Lua

return {
{
"hrsh7th/cmp-nvim-lsp",
},
{
"L3MON4D3/LuaSnip",
version="V2.*"
},
{
"saadparwaiz1/cmp_luasnip",
},
{
"rafamadriz/friendly-snippets"
},
{
"hrsh7th/nvim-cmp",
event = { "InsertEnter", "CmdlineEnter" },
config = function()
local luasnip = require("luasnip")
local cmp = require("cmp")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = {
-- ... Your other mappings ...
['<CR>'] = cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
})
})
end
}
}