local cmp = require("cmp") cmp.setup { snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, window = { completion = { border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, }, documentation = { border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, }, }, -- window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), -- }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [""] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close(), }, -- Accept currently selected item. If none selected, `select` first item. -- Set `select` to `false` to only confirm explicitly selected items. [""] = cmp.mapping.confirm { select = false }, [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, { "i", "s" }) }), sources = cmp.config.sources( { { name = 'nvim_lsp' }, { name = 'nvim_lsp_signature_help' }, { name = 'vsnip' }, { name = 'nvim_lua' }, { name = 'path' }, { name = 'buffer' }, } ), experimental = { ghost_text = false, native_menu = false, }, } -- Setup configuration for a specific type of file cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, }, { { name = 'buffer' }, }) }) -- Использовать источник буфера для `/` и `?` (если вы включили `native_menu`, это больше не будет работать) cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) -- Используйте cmdline и источник пути для ':' (если вы включили `native_menu`, это больше не будет работать) cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) -- Настройка конфига LSP local capabilities = require('cmp_nvim_lsp').default_capabilities() -- Замените на нужный lsp-сервер (для каждого нужно создавать отдельный параметр) -- require('lspconfig')[''].setup {capabilities = capabilities} require('lspconfig')['pyright'].setup { capabilities = capabilities } -- Подстановка скобок к подсказкам, которым это нужно (дополнение для nvim-autopairs) local cmp_autopairs = require('nvim-autopairs.completion.cmp') cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() )