Add multiple plugin
This commit is contained in:
@@ -1,23 +1,44 @@
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp", -- Source LSP
|
||||
"hrsh7th/cmp-buffer", -- Source mots du buffer actuel
|
||||
"hrsh7th/cmp-path", -- Source chemins de fichiers
|
||||
"L3MON4D3/LuaSnip", -- Moteur de snippets
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip", -- LE PONT : permet à nvim-cmp de voir les snippets
|
||||
"rafamadriz/friendly-snippets", -- LA BIBLIOTHÈQUE
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
-- CHARGEMENT : C'est cette ligne qui active friendly-snippets
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- OBLIGATOIRE : Dit à nvim-cmp comment étendre le snippet
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
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(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Entrée pour valider
|
||||
['<Tab>'] = cmp.mapping.select_next_item(), -- Tab pour descendre
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
-- Navigation intelligente dans le snippet avec Tab
|
||||
['<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' }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim-lsp' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- On ajoute la source snippet ici
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user