|
|
@ -9,24 +9,57 @@ return { |
|
|
|
{ |
|
|
|
'hrsh7th/nvim-cmp', |
|
|
|
event = 'InsertEnter', |
|
|
|
dependencies = { |
|
|
|
{ "L3MON4D3/LuaSnip" }, |
|
|
|
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required |
|
|
|
{ 'hrsh7th/cmp-buffer' }, -- Optional |
|
|
|
{ 'hrsh7th/cmp-path' }, -- Optional |
|
|
|
{ 'saadparwaiz1/cmp_luasnip' }, -- Optional |
|
|
|
{ 'hrsh7th/cmp-nvim-lua' }, -- Optional |
|
|
|
}, |
|
|
|
config = function() |
|
|
|
local cmp = require('cmp') |
|
|
|
local luasnip = require("luasnip") |
|
|
|
local cmp_select = { behavior = cmp.SelectBehavior.Select } |
|
|
|
|
|
|
|
cmp.setup({ |
|
|
|
sources = { |
|
|
|
sources = cmp.config.sources({ |
|
|
|
{ name = 'nvim_lsp' }, |
|
|
|
{ name = 'luasnip' }, |
|
|
|
{ name = 'path' }, |
|
|
|
{ name = 'buffer' }, |
|
|
|
{ name = 'nvim_lua' }, |
|
|
|
}, { |
|
|
|
{ name = 'buffer' }, |
|
|
|
}), |
|
|
|
completion = { |
|
|
|
completeopt = 'menu,menuone,noinsert' |
|
|
|
}, |
|
|
|
mapping = cmp.mapping.preset.insert({ |
|
|
|
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), |
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), |
|
|
|
['<C-s>'] = cmp.mapping.confirm({ select = true }), |
|
|
|
["<C-Space>"] = cmp.mapping.complete(), |
|
|
|
['<Tab>'] = nil, |
|
|
|
['<Tab>'] = cmp.mapping.select_next_item(cmp_select), |
|
|
|
['<S-Tab>'] = nil, |
|
|
|
["<CR>"] = cmp.mapping({ |
|
|
|
i = function(fallback) |
|
|
|
-- and cmp.get_selected_entry() |
|
|
|
if cmp.visible() then |
|
|
|
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }) |
|
|
|
else |
|
|
|
fallback() |
|
|
|
end |
|
|
|
end, |
|
|
|
s = cmp.mapping.confirm({ select = true }), |
|
|
|
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), |
|
|
|
}), |
|
|
|
}), |
|
|
|
experimental = { |
|
|
|
ghost_text = true |
|
|
|
}, |
|
|
|
snippet = { |
|
|
|
expand = function(args) |
|
|
|
vim.snippet.expand(args.body) |
|
|
|
luasnip.lsp_expand(args.body) |
|
|
|
end, |
|
|
|
}, |
|
|
|
}) |
|
|
@ -42,6 +75,7 @@ return { |
|
|
|
{ 'hrsh7th/cmp-nvim-lsp' }, |
|
|
|
{ 'williamboman/mason.nvim' }, |
|
|
|
{ 'williamboman/mason-lspconfig.nvim' }, |
|
|
|
{ "L3MON4D3/LuaSnip" } |
|
|
|
}, |
|
|
|
init = function() |
|
|
|
-- Reserve a space in the gutter |
|
|
|