113 lines
2.5 KiB
Lua
113 lines
2.5 KiB
Lua
return {
|
|
"hrsh7th/nvim-cmp",
|
|
event = { "InsertEnter", "CmdlineEnter" },
|
|
dependencies = {
|
|
"L3MON4D3/LuaSnip",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-path",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-cmdline",
|
|
},
|
|
config = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
local kind_icons = {
|
|
Text = "",
|
|
Method = "",
|
|
Function = "",
|
|
Constructor = "",
|
|
Field = "",
|
|
Variable = "",
|
|
Class = "",
|
|
Interface = "",
|
|
Module = "",
|
|
Property = "",
|
|
Unit = "",
|
|
Value = "",
|
|
Enum = "",
|
|
Keyword = "",
|
|
Snippet = "",
|
|
Color = "",
|
|
File = "",
|
|
Reference = "",
|
|
Folder = "",
|
|
EnumMember = "",
|
|
Constant = "",
|
|
Struct = "",
|
|
Event = "",
|
|
Operator = "",
|
|
TypeParameter = "",
|
|
}
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
["<C-j>"] = cmp.mapping.select_next_item(),
|
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
["<C-k>"] = cmp.mapping.select_prev_item(),
|
|
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "path" },
|
|
{ name = "buffer" },
|
|
}),
|
|
performance = {
|
|
debounce = 60,
|
|
fetching_timeout = 200,
|
|
max_view_entries = 30,
|
|
},
|
|
window = {
|
|
completion = {
|
|
border = "rounded",
|
|
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
|
|
},
|
|
documentation = {
|
|
border = "rounded",
|
|
},
|
|
},
|
|
formatting = {
|
|
fields = { "kind", "abbr", "menu" },
|
|
format = function(_, vim_item)
|
|
vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind] or "", vim_item.kind)
|
|
return vim_item
|
|
end,
|
|
},
|
|
})
|
|
|
|
-- `/` and `?` cmdline uses buffer source
|
|
cmp.setup.cmdline({ "/", "?" }, {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = {
|
|
{ name = "buffer" },
|
|
},
|
|
})
|
|
|
|
-- `:` cmdline uses path and cmdline source
|
|
cmp.setup.cmdline(":", {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = cmp.config.sources({
|
|
{ name = "path" },
|
|
}, {
|
|
{ name = "cmdline" },
|
|
}),
|
|
})
|
|
|
|
-- gitcommit filetype config
|
|
cmp.setup.filetype("gitcommit", {
|
|
sources = cmp.config.sources({
|
|
{ name = "cmp_git" },
|
|
}, {
|
|
{ name = "buffer" },
|
|
}),
|
|
})
|
|
end,
|
|
}
|