my-nvim-config/laptop/plugin/cmp.lua

73 lines
2.4 KiB
Lua
Raw Normal View History

2024-03-13 14:07:20 -05:00
local cmp = require('cmp')
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
cmp.setup({
snippet = {
2024-03-25 13:44:31 -05:00
-- REQUIRED - you must specify a snippet engine
expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
2024-03-13 14:07:20 -05:00
},
window = {
2024-03-25 13:44:31 -05:00
completion = cmp.config.window.bordered(winhighlight),
documentation = cmp.config.window.bordered(winhighlight),
2024-03-13 14:07:20 -05:00
},
mapping = cmp.mapping.preset.insert({
2024-03-25 13:44:31 -05:00
['<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 = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
2024-03-13 14:07:20 -05:00
}),
sources = cmp.config.sources({
2024-03-25 13:44:31 -05:00
{ name = 'nvim_lsp' },
{ name = "vimtex" },
-- { name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
{ name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, { { name = 'buffer' } }
2024-03-13 14:07:20 -05:00
),
experimental = { ghost_text = true },
2024-03-25 13:44:31 -05:00
})
2024-03-13 14:07:20 -05:00
2024-03-25 13:44:31 -05:00
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
2024-03-13 14:07:20 -05:00
sources = cmp.config.sources({
2024-03-25 13:44:31 -05:00
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
2024-03-13 14:07:20 -05:00
}, {
2024-03-25 13:44:31 -05:00
{ name = 'buffer' },
2024-03-13 14:07:20 -05:00
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
2024-03-25 13:44:31 -05:00
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
2024-03-13 14:07:20 -05:00
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
2024-03-25 13:44:31 -05:00
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
2024-03-13 14:07:20 -05:00
})
-- Insert `(` after select function or method item
cmp.event:on(
2024-03-25 13:44:31 -05:00
'confirm_done',
cmp_autopairs.on_confirm_done({
filetypes = {
tex = false
}
})
2024-03-13 14:07:20 -05:00
)