ultisnips

This commit is contained in:
unknown
2024-12-27 10:08:38 +08:00
parent 7d5dcc7660
commit 0cc45c6281
2 changed files with 39 additions and 13 deletions
+24
View File
@@ -27,10 +27,18 @@ return {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"SirVer/ultisnips",
"quangnguyen30192/cmp-nvim-ultisnips"
},
config = function()
local cmp = require('cmp')
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
cmp.setup({
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end
},
completion = {
keyword_length = 1,
max_item_count = 6
@@ -39,11 +47,27 @@ return {
{ name = "nvim_lsp", keyword_length = 1, max_item_count = 6 },
{ name = "buffer", keyword_length = 1, max_item_count = 6 },
{ name = "path", keyword_length = 1, max_item_count = 6 },
{ name = "ultisnips" },
},
mapping = {
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 'c'}),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 'c'}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- accept currently selected item
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.expand_or_jump_forwards(fallback)
end,
{ "i", "s", "c" }
),
["<S-Tab>"] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.jump_backwards(fallback)
end,
{ "i", "s", "c" }
),
},
sorting = {
comparators = {