122 lines
3.0 KiB
Lua
122 lines
3.0 KiB
Lua
require("lazy.types")
|
|
---@type LazySpec[]
|
|
return {
|
|
{
|
|
"L3MON4D3/LuaSnip",
|
|
dependencies = {
|
|
"rafamadriz/friendly-snippets",
|
|
},
|
|
config = function()
|
|
local lua_snippets = vim.fn.stdpath("config") .. "/luasnip"
|
|
local vscode_snippets = vim.fn.stdpath("config") .. "/snippets"
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
require("luasnip.loaders.from_vscode").lazy_load({ paths = { vscode_snippets } })
|
|
require("luasnip.loaders.from_lua").lazy_load({ paths = { lua_snippets } })
|
|
end,
|
|
lazy = true,
|
|
},
|
|
{
|
|
"windwp/nvim-autopairs",
|
|
event = "InsertEnter",
|
|
config = true,
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
event = { "InsertEnter" },
|
|
dependencies = {
|
|
"LuaSnip",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"onsails/lspkind.nvim",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
"nvim-autopairs",
|
|
"chrisgrieser/cmp-nerdfont",
|
|
},
|
|
opts = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
local lspkind = require("lspkind")
|
|
---@type cmp.ConfigSchema
|
|
return {
|
|
enabled = function()
|
|
local disabled = false
|
|
disabled = disabled or (vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt")
|
|
disabled = disabled or (vim.fn.reg_recording() ~= "")
|
|
disabled = disabled or (vim.fn.reg_executing() ~= "")
|
|
disabled = disabled or require("cmp.config.context").in_treesitter_capture("comment")
|
|
return not disabled
|
|
end,
|
|
preselect = cmp.PreselectMode.None,
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
window = {
|
|
completion = {
|
|
scrollbar = false,
|
|
},
|
|
},
|
|
mapping = {
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_locally_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.locally_jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<CR>"] = cmp.mapping({
|
|
i = function(fallback)
|
|
if cmp.visible() and cmp.get_active_entry() then
|
|
cmp.confirm({
|
|
behaviour = cmp.ConfirmBehavior.Replace,
|
|
select = false,
|
|
})
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
s = cmp.mapping.confirm({ select = false }),
|
|
c = cmp.mapping.confirm({
|
|
behaviour = cmp.ConfirmBehavior.Insert,
|
|
select = false,
|
|
}),
|
|
}),
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = "lazydev" },
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "nerdfont" },
|
|
}),
|
|
formatting = {
|
|
format = lspkind.cmp_format({
|
|
mode = "symbol_text",
|
|
menu = {
|
|
nvim_lsp = "[LSP]",
|
|
luasnip = "[SNP]",
|
|
lazydev = "[LZY]",
|
|
nerdfont = "[SYM]",
|
|
},
|
|
maxwidth = 50,
|
|
ellipsis_char = "",
|
|
}),
|
|
},
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
}
|