mirror of
https://github.com/arkorty/Neolite.git
synced 2026-03-17 16:51:42 +00:00
63 lines
1.4 KiB
Lua
63 lines
1.4 KiB
Lua
local ok, cmp = pcall(require, "cmp")
|
|
if not ok then
|
|
return
|
|
end
|
|
|
|
local luasnip_ok, luasnip = pcall(require, "luasnip")
|
|
if not luasnip_ok then
|
|
return
|
|
end
|
|
|
|
local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode")
|
|
if not luasnip_vscode_ok then
|
|
return
|
|
end
|
|
|
|
luasnip_vscode.lazy_load()
|
|
|
|
cmp.setup({
|
|
view = {
|
|
--entries = { name = "custom", selection_order = "near_cursor" },
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
|
end,
|
|
},
|
|
mapping = {
|
|
["<C-k>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-j>"] = cmp.mapping.scroll_docs(4),
|
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
|
["<CR>"] = cmp.mapping.confirm(),
|
|
},
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "buffer" },
|
|
{ name = "path" },
|
|
},
|
|
confirm_opts = {
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = false,
|
|
},
|
|
experimental = {
|
|
ghost_text = false,
|
|
},
|
|
formatting = {
|
|
fields = { "kind", "abbr", "menu" },
|
|
format = function(entry, vim_item)
|
|
local lk_ok, lspkind = pcall(require, "lspkind")
|
|
if not lk_ok then
|
|
return
|
|
end
|
|
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
|
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
|
kind.kind = " " .. (strings[1] or "") .. " "
|
|
kind.menu = " (" .. (strings[2] or "") .. ")"
|
|
|
|
return kind
|
|
end,
|
|
},
|
|
})
|