84 lines
2.5 KiB
Lua
84 lines
2.5 KiB
Lua
return {
|
|
{
|
|
'hrsh7th/nvim-cmp',
|
|
event = 'InsertEnter',
|
|
dependencies = {
|
|
{
|
|
'L3MON4D3/LuaSnip',
|
|
build = (function()
|
|
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
|
|
return
|
|
end
|
|
return 'make install_jsregexp'
|
|
end)(),
|
|
dependencies = {
|
|
-- `friendly-snippets` contains a variety of premade snippets.
|
|
-- See the README about individual language/framework/plugin snippets:
|
|
-- https://github.com/rafamadriz/friendly-snippets
|
|
-- {
|
|
-- 'rafamadriz/friendly-snippets',
|
|
-- config = function()
|
|
-- require('luasnip.loaders.from_vscode').lazy_load()
|
|
-- end,
|
|
-- },
|
|
},
|
|
},
|
|
'saadparwaiz1/cmp_luasnip',
|
|
|
|
-- Other completions
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
'hrsh7th/cmp-path',
|
|
},
|
|
config = function()
|
|
-- See `:help cmp`
|
|
local cmp = require 'cmp'
|
|
local luasnip = require 'luasnip'
|
|
luasnip.config.setup {}
|
|
|
|
cmp.setup {
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
completion = {
|
|
autocomplete = false, -- Use C-Space
|
|
completeopt = 'menu,menuone,noinsert',
|
|
},
|
|
-- `:help ins-completion`
|
|
mapping = cmp.mapping.preset.insert {
|
|
['<down>'] = cmp.mapping.select_next_item(),
|
|
['<up>'] = cmp.mapping.select_prev_item(),
|
|
['<left>'] = cmp.mapping.scroll_docs(-4),
|
|
['<right>'] = cmp.mapping.scroll_docs(4),
|
|
['<Tab>'] = cmp.mapping.confirm { select = true },
|
|
['<C-g>'] = cmp.mapping.abort(),
|
|
['<C-h>'] = cmp.mapping.complete {},
|
|
['<C-right>'] = cmp.mapping(function()
|
|
if luasnip.expand_or_locally_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
end
|
|
end, { 'i', 's' }),
|
|
['<C-left>'] = cmp.mapping(function()
|
|
if luasnip.locally_jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
end
|
|
end, { 'i', 's' }),
|
|
['<C-n>'] = cmp.config.disable,
|
|
['<C-p>'] = cmp.config.disable,
|
|
},
|
|
sources = {
|
|
{
|
|
name = 'lazydev',
|
|
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
|
|
group_index = 0,
|
|
},
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' },
|
|
{ name = 'path' },
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
}
|