dotfiles/.config/nvim/lua/my/completion.lua

78 lines
2.5 KiB
Lua

require('my/plugins')
packer.use {
'https://github.com/hrsh7th/nvim-cmp',
requires = {
{
'https://github.com/hrsh7th/cmp-nvim-lsp',
requires = 'https://github.com/neovim/nvim-lspconfig';
},
'https://github.com/hrsh7th/cmp-buffer',
'https://github.com/hrsh7th/cmp-path',
'https://github.com/hrsh7th/cmp-cmdline',
{
'https://github.com/saadparwaiz1/cmp_luasnip',
requires = 'https://github.com/L3MON4D3/LuaSnip'
},
},
config = function()
local cmp = require'cmp'
if cmp == nil then
return
end
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<S-PageUp>'] = cmp.mapping.scroll_docs(-4),
['<S-PageDown>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<End>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<tab>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' },
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end
}