2022-08-11 16:22:36 +02:00
|
|
|
require('my/plugins')
|
2022-08-08 11:07:10 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
local cmp = require('cmp')
|
|
|
|
local luasnip = require('luasnip')
|
2022-08-08 11:07:10 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
if cmp and luasnip then
|
|
|
|
cmp.setup({
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
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(),
|
|
|
|
['<Left>'] = cmp.mapping.abort(),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
|
|
|
['<Tab>'] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif luasnip.expandable() then
|
|
|
|
luasnip.expand()
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end),
|
|
|
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
elseif luasnip.jumpable(-1) then
|
|
|
|
luasnip.kump(-1)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
}),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'luasnip' },
|
|
|
|
}, {
|
|
|
|
{ name = 'buffer' },
|
2022-08-12 19:54:40 +02:00
|
|
|
})
|
2022-08-15 01:29:31 +02:00
|
|
|
})
|
2022-08-08 11:07:10 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
-- set configuration for specific filetypes
|
|
|
|
cmp.setup.filetype('lua', {
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'luasnip' },
|
|
|
|
{ name = 'nvim_lua' },
|
|
|
|
}, {
|
|
|
|
{ name = 'buffer' },
|
2022-08-13 21:28:42 +02:00
|
|
|
})
|
2022-08-15 01:29:31 +02:00
|
|
|
})
|
2022-08-13 21:28:42 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
cmp.setup.filetype('gitcommit', {
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'dictionary' }
|
|
|
|
}, {
|
|
|
|
{ name = 'buffer' }
|
2022-08-08 13:57:38 +02:00
|
|
|
})
|
2022-08-15 01:29:31 +02:00
|
|
|
})
|
2022-08-08 11:07:10 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
-- Use buffer source for `/`
|
|
|
|
cmp.setup.cmdline('/', {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = {
|
|
|
|
{ name = 'buffer' }
|
|
|
|
}
|
|
|
|
})
|
2022-08-13 21:28:42 +02:00
|
|
|
|
2022-08-15 01:29:31 +02:00
|
|
|
-- Use cmdline & path source for ':'
|
|
|
|
cmp.setup.cmdline(':', {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'path' }
|
|
|
|
}, {
|
|
|
|
{ name = 'cmdline' }
|
2022-08-13 21:28:42 +02:00
|
|
|
})
|
2022-08-15 01:29:31 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
require('cmp_dictionary').setup({
|
|
|
|
dic = {
|
|
|
|
['gitcommit'] =
|
|
|
|
vim.fn.stdpath('config') .. '/resources/git.dict',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|