Nvim: move to nvim-cmp

This commit is contained in:
Robert Kmieć
2022-12-12 01:11:27 +01:00
parent ba30d83f9e
commit 68774a8c80
8 changed files with 172 additions and 147 deletions

View File

@@ -1,73 +1,68 @@
-- Setup nvim-cmp.
--local cmp = require'cmp'
--
--cmp.setup({
-- snippet = {
-- expand = function(args)
-- -- For `vsnip` user.
-- -- vim.fn["vsnip#anonymous"](args.body)
--
-- -- For `luasnip` user.
-- -- require('luasnip').lsp_expand(args.body)
--
-- -- For `ultisnips` user.
-- vim.fn["UltiSnips#Anon"](args.body)
-- end,
-- },
-- mapping = cmp.mapping.preset.insert({
-- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
-- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
-- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
-- ['<tab>'] = cmp.mapping.confirm({ select = true }),
-- ['<C-e>'] = cmp.mapping({
-- i = cmp.mapping.abort(),
-- c = cmp.mapping.close(),
-- }),
-- }),
-- sources = cmp.config.sources({
-- { name = 'nvim_lsp' },
--
-- { name = 'path' },
--
-- { name = 'ultisnips' },
--
-- { name = 'calc' },
--
-- { name = 'cmp_matlab' },
--
-- { name = 'cmp_git' },
-- }, {
-- { name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
-- }),
-- --experimental = {
-- -- native_menu = false
-- --}
--
-- sorting = {
-- comparators = {
-- cmp.config.compare.offset,
-- cmp.config.compare.exact,
-- cmp.config.compare.recently_used,
-- require("clangd_extensions.cmp_scores"),
-- cmp.config.compare.kind,
-- cmp.config.compare.sort_text,
-- cmp.config.compare.length,
-- cmp.config.compare.order,
-- },
-- },
--})
--
--cmp.setup.cmdline('/', {
-- sources = {
-- { name = 'buffer' }
-- }
--})
--
--cmp.setup.cmdline(':', {
-- sources = {
-- { name = 'cmdline' }
-- },
-- mapping = cmp.mapping.preset.cmdline()
--})
--
--require("cmp_git").setup()
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('snippy').expand_snippet(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 }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'snippy' },
{ name = 'calc' },
{ name = 'cmp_matlab' },
{ name = 'cmp_git' },
}, {
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
}),
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.recently_used,
require("clangd_extensions.cmp_scores"),
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
})
cmp.setup.cmdline({'/', '?'}, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{name = 'cmp_git' },
}, {
{name = 'buffer' }
})
})
require("cmp_git").setup()