You've already forked dotfiles
67 lines
1.8 KiB
Lua
67 lines
1.8 KiB
Lua
vim.pack.add({
|
|
'https://github.com/hrsh7th/nvim-cmp',
|
|
'https://github.com/hrsh7th/cmp-nvim-lsp',
|
|
'https://github.com/hrsh7th/cmp-buffer',
|
|
'https://github.com/hrsh7th/cmp-path',
|
|
'https://github.com/hrsh7th/cmp-cmdline',
|
|
'https://github.com/hrsh7th/cmp-nvim-lua',
|
|
})
|
|
|
|
local cmp = require('cmp')
|
|
|
|
cmp.setup {
|
|
completion = {
|
|
completeopt = 'menu,menuone,noinsert',
|
|
},
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
mapping = {
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
['<C-j>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-k>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-space>'] = cmp.mapping.complete(), -- TODO: Overlaps with completion(? possibly doesn't due to state)
|
|
['<C-y>'] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
}),
|
|
},
|
|
formatting = {
|
|
format = function(entry, vim_item)
|
|
vim_item.menu = ({
|
|
buffer = '[Buf]',
|
|
luasnip = '[Snips]',
|
|
nvim_lsp = '[LSP]',
|
|
nvim_lua = '[Lua]',
|
|
})[entry.source.name]
|
|
return vim_item
|
|
end,
|
|
field = { 'abbr', 'kind', 'menu' }
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' },
|
|
{ name = 'path' },
|
|
{ name = 'render-markdown' },
|
|
}, {
|
|
{ name = 'buffer' },
|
|
})
|
|
}
|
|
|
|
cmp.setup.cmdline(':', {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = cmp.config.sources({
|
|
{ name = 'path' },
|
|
}, {
|
|
{ name = 'cmdline' },
|
|
})
|
|
})
|
|
|
|
cmp.setup.cmdline({ '/', '?' }, {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = {
|
|
{ name = 'buffer' }
|
|
}
|
|
})
|