2022-08-08 11:07:10 +02:00
|
|
|
require('plugins')
|
2022-08-08 13:57:38 +02:00
|
|
|
require('lsp')
|
2022-08-08 11:07:10 +02:00
|
|
|
|
2022-08-08 13:57:38 +02:00
|
|
|
use 'https://github.com/hrsh7th/cmp-nvim-lsp'
|
|
|
|
use 'https://github.com/hrsh7th/cmp-buffer'
|
|
|
|
use 'https://github.com/hrsh7th/cmp-path'
|
|
|
|
use 'https://github.com/hrsh7th/cmp-cmdline'
|
|
|
|
use 'https://github.com/hrsh7th/cmp-nvim-lua'
|
|
|
|
use {
|
|
|
|
'https://github.com/hrsh7th/nvim-cmp',
|
|
|
|
config = function()
|
|
|
|
local cmp = require'cmp'
|
|
|
|
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({
|
|
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
|
|
|
['<tab>'] = cmp.mapping.confirm({ select = true }),
|
|
|
|
}),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'luasnip' }, -- For luasnip users.
|
|
|
|
}, {
|
|
|
|
{ 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
|
|
|
-- setup lspconfig
|
|
|
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(
|
|
|
|
vim.lsp.protocol.make_client_capabilities())
|
|
|
|
-- add for each enabled lsp server
|
|
|
|
require('lspconfig')['clangd'].setup {
|
|
|
|
capabilities = capabilities
|
|
|
|
}
|
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
|
|
|
|
}
|