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

111 lines
3.1 KiB
Lua
Raw Normal View History

require('my/plugins')
2022-08-08 11:07:10 +02:00
2022-08-08 20:27:58 +02:00
packer.use {
2022-08-08 13:57:38 +02:00
'https://github.com/hrsh7th/nvim-cmp',
2022-08-12 17:28:52 +02:00
requires = {
{
'https://github.com/saadparwaiz1/cmp_luasnip',
requires = 'https://github.com/L3MON4D3/LuaSnip'
},
},
2022-08-08 13:57:38 +02:00
config = function()
local cmp = require'cmp'
2022-08-12 14:05:53 +02:00
if cmp == nil then
return
end
2022-08-08 13:57:38 +02:00
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
2022-08-08 13:57:38 +02:00
},
mapping = cmp.mapping.preset.insert({
2022-08-12 18:17:19 +02:00
['<S-PageUp>'] = cmp.mapping.scroll_docs(-4),
['<S-PageDown>'] = cmp.mapping.scroll_docs(4),
2022-08-08 13:57:38 +02:00
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<End>'] = cmp.mapping.abort(),
2022-08-08 13:57:38 +02:00
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<tab>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
2022-08-08 13:57:38 +02:00
}, {
{ name = 'buffer' },
})
})
2022-08-08 11:07:10 +02:00
2022-08-08 13:57:38 +02:00
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' },
}, {
{ name = 'buffer' },
})
})
2022-08-08 11:07:10 +02:00
2022-08-08 13:57:38 +02:00
-- 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' }
}
})
2022-08-08 11:07:10 +02:00
2022-08-08 13:57:38 +02:00
-- 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' }
})
})
2022-08-08 11:07:10 +02:00
2022-08-08 13:57:38 +02:00
cmp.setup.filetype('lua', {
sources = cmp.config.sources({
{ name = 'nvim_lua' },
}, {
{ name = 'buffer' },
})
})
end
}
2022-08-12 15:21:26 +02:00
packer.use {
'https://github.com/hrsh7th/cmp-nvim-lsp',
requires = 'https://github.com/hrsh7th/nvim-cmp',
config = function()
require'cmp'.setup {
sources = {
name = 'nvim_lsp'
}
}
end
}
packer.use {
'https://github.com/hrsh7th/cmp-buffer',
requires = 'https://github.com/hrsh7th/nvim-cmp',
}
packer.use {
'https://github.com/hrsh7th/cmp-path',
requires = 'https://github.com/hrsh7th/nvim-cmp',
}
packer.use {
'https://github.com/hrsh7th/cmp-cmdline',
requires = 'https://github.com/hrsh7th/nvim-cmp',
}
-- packer.use {
-- 'https://github.com/hrsh7th/cmp-nvim-lua',
-- requires = 'https://github.com/hrsh7th/nvim-cmp',
-- }