|
@ -29,8 +29,8 @@ function M.setup() |
|
|
})[entry.source.name] |
|
|
})[entry.source.name] |
|
|
return vim_item |
|
|
return vim_item |
|
|
end, |
|
|
end, |
|
|
}, |
|
|
|
|
|
mapping = { |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
mapping = { |
|
|
["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), |
|
|
["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), |
|
|
["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), |
|
|
["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), |
|
|
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }), |
|
|
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }), |
|
@ -38,77 +38,81 @@ function M.setup() |
|
|
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), |
|
|
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), |
|
|
["<C-e>"] = cmp.mapping { i = cmp.mapping.close(), c = cmp.mapping.close() }, |
|
|
["<C-e>"] = cmp.mapping { i = cmp.mapping.close(), c = cmp.mapping.close() }, |
|
|
["<CR>"] = cmp.mapping { |
|
|
["<CR>"] = cmp.mapping { |
|
|
i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, |
|
|
|
|
|
c = function(fallback) |
|
|
|
|
|
|
|
|
i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, |
|
|
|
|
|
c = function(fallback) |
|
|
|
|
|
if cmp.visible() then |
|
|
|
|
|
cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } |
|
|
|
|
|
else |
|
|
|
|
|
fallback() |
|
|
|
|
|
end |
|
|
|
|
|
end, |
|
|
|
|
|
}, |
|
|
|
|
|
["<Tab>"] = cmp.mapping( |
|
|
|
|
|
function(fallback) |
|
|
|
|
|
if cmp.visible() then |
|
|
|
|
|
cmp.select_next_item() |
|
|
|
|
|
elseif luasnip.expand_or_jumpable() then |
|
|
|
|
|
luasnip.expand_or_jump() |
|
|
|
|
|
elseif has_words_before() then |
|
|
|
|
|
cmp.complete() |
|
|
|
|
|
else |
|
|
|
|
|
fallback() |
|
|
|
|
|
end |
|
|
|
|
|
end, { |
|
|
|
|
|
"i", |
|
|
|
|
|
"s", |
|
|
|
|
|
"c", |
|
|
|
|
|
}), |
|
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback) |
|
|
if cmp.visible() then |
|
|
if cmp.visible() then |
|
|
cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } |
|
|
|
|
|
|
|
|
cmp.select_prev_item() |
|
|
|
|
|
elseif luasnip.jumpable(-1) then |
|
|
|
|
|
luasnip.jump(-1) |
|
|
else |
|
|
else |
|
|
fallback() |
|
|
|
|
|
|
|
|
fallback() |
|
|
end |
|
|
end |
|
|
end, |
|
|
|
|
|
}, |
|
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback) |
|
|
|
|
|
if cmp.visible() then |
|
|
|
|
|
cmp.select_next_item() |
|
|
|
|
|
elseif luasnip.expand_or_jumpable() then |
|
|
|
|
|
luasnip.expand_or_jump() |
|
|
|
|
|
elseif has_words_before() then |
|
|
|
|
|
cmp.complete() |
|
|
|
|
|
else |
|
|
|
|
|
fallback() |
|
|
|
|
|
end |
|
|
|
|
|
end, { |
|
|
end, { |
|
|
"i", |
|
|
"i", |
|
|
"s", |
|
|
"s", |
|
|
"c", |
|
|
"c", |
|
|
}), |
|
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback) |
|
|
|
|
|
if cmp.visible() then |
|
|
|
|
|
cmp.select_prev_item() |
|
|
|
|
|
elseif luasnip.jumpable(-1) then |
|
|
|
|
|
luasnip.jump(-1) |
|
|
|
|
|
else |
|
|
|
|
|
fallback() |
|
|
|
|
|
end |
|
|
|
|
|
end, { |
|
|
|
|
|
"i", |
|
|
|
|
|
"s", |
|
|
|
|
|
"c", |
|
|
|
|
|
}), |
|
|
|
|
|
}, |
|
|
|
|
|
sources = { |
|
|
|
|
|
{ name = "nvim_lsp" }, |
|
|
|
|
|
{ name = "treesitter" }, |
|
|
|
|
|
{ name = "buffer" }, |
|
|
|
|
|
{ name = "luasnip" }, |
|
|
|
|
|
{ name = "nvim_lua" }, |
|
|
|
|
|
{ name = "path" }, |
|
|
|
|
|
-- { name = "spell" }, |
|
|
|
|
|
-- { name = "emoji" }, |
|
|
|
|
|
-- { name = "calc" }, |
|
|
|
|
|
}, |
|
|
|
|
|
window = { |
|
|
|
|
|
documentation = { |
|
|
|
|
|
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, |
|
|
|
|
|
winhighlight = "NormalFloat:NormalFloat,FloatBorder:TelescopeBorder", |
|
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
sources = { |
|
|
|
|
|
{ name = "nvim_lsp" }, |
|
|
|
|
|
{ name = "treesitter" }, |
|
|
|
|
|
{ name = "buffer" }, |
|
|
|
|
|
{ name = "luasnip" }, |
|
|
|
|
|
{ name = "nvim_lua" }, |
|
|
|
|
|
{ name = "path" }, |
|
|
|
|
|
-- { name = "spell" }, |
|
|
|
|
|
-- { name = "emoji" }, |
|
|
|
|
|
-- { name = "calc" }, |
|
|
|
|
|
}, |
|
|
|
|
|
window = { |
|
|
|
|
|
documentation = { |
|
|
|
|
|
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, |
|
|
|
|
|
winhighlight = "NormalFloat:NormalFloat,FloatBorder:TelescopeBorder", |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
-- Use buffer source for `/` |
|
|
-- Use buffer source for `/` |
|
|
cmp.setup.cmdline("/", { |
|
|
cmp.setup.cmdline("/", { |
|
|
|
|
|
mapping = cmp.mapping.preset.cmdline(), |
|
|
sources = { |
|
|
sources = { |
|
|
{ name = "buffer" }, |
|
|
{ name = "buffer" }, |
|
|
}, |
|
|
}, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':' |
|
|
|
|
|
cmp.setup.cmdline(":", { |
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). |
|
|
|
|
|
cmp.setup.cmdline(':', { |
|
|
|
|
|
mapping = cmp.mapping.preset.cmdline(), |
|
|
sources = cmp.config.sources({ |
|
|
sources = cmp.config.sources({ |
|
|
{ name = "path" }, |
|
|
|
|
|
|
|
|
{ name = 'path' } |
|
|
}, { |
|
|
}, { |
|
|
{ name = "cmdline" }, |
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
{ name = 'cmdline' } |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
end |
|
|
end |
|
|