feat(update): update

This commit is contained in:
darwincereska
2025-12-01 15:17:21 -05:00
parent fd83a29f1e
commit de8c6245ec
31 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,130 @@
return {
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"f3fora/cmp-spell",
"rafamadriz/friendly-snippets",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
-- Load VSCode-style snippets
require("luasnip.loaders.from_vscode").lazy_load()
-- Highlighting for completion windows
vim.api.nvim_set_hl(0, "CmpBorder", { link = "FloatBorder" })
vim.api.nvim_set_hl(0, "CmpDocBorder", { link = "FloatBorder" })
vim.api.nvim_set_hl(0, "CmpDocNormal", { link = "NormalFloat" })
local snippets_enabled = true
-- Toggle function for snippets
function toggle_snippets()
snippets_enabled = not snippets_enabled
end
-- Key mapping to toggle snippets
vim.api.nvim_set_keymap('n', '<Leader>ts', ':lua toggle_snippets()<CR>', { noremap = true, silent = true })
cmp.setup({
snippet = {
expand = function(args)
if snippets_enabled then
luasnip.lsp_expand(args.body)
end
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippets_enabled and 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 snippets_enabled and luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer", keyword_length = 3 },
{ name = "path" },
{ name = "spell" },
}),
window = {
completion = cmp.config.window.bordered({
border = "rounded",
winhighlight = "Normal:NormalFloat,FloatBorder:CmpBorder",
scrollbar = true,
winblend = 8,
}),
documentation = cmp.config.window.bordered({
border = "rounded",
winhighlight = "Normal:CmpDocNormal,FloatBorder:CmpDocBorder",
winblend = 8,
max_width = 60,
max_height = 20,
}),
},
formatting = {
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
spell = "[Spell]",
})[entry.source.name]
return vim_item
end,
},
})
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
end,
},
}