local cmp = require('cmp') local snippy = require('snippy') -- Neovim shifts wide floating menus back onto the screen. nvim-cmp otherwise -- anchors docs to the requested column, which can overlap the shifted menu. local entries_view = require('cmp.view.custom_entries_view') entries_view.info = function(self) local info = self.entries_win:info() info.col = math.max(0, math.min(info.col, vim.o.columns - info.width)) return info end vim.opt.completeopt = { 'menuone', 'noselect' } vim.opt.shortmess:append('c') cmp.setup({ window = { completion = cmp.config.window.bordered({ border = 'rounded' }), documentation = cmp.config.window.bordered({ border = 'rounded', -- Leave a column between the menu and docs, on either side. col_offset = 1, }), }, snippet = { expand = function(args) snippy.expand_snippet(args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.abort(), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'path' }, { name = 'snippy' }, }, { { name = 'buffer' }, }), }) snippy.setup({ mappings = { is = { [''] = 'expand_or_advance', [''] = 'previous', }, }, })