100 lines
1.9 KiB
Lua
Raw Normal View History

2023-08-22 14:51:35 +00:00
local icons = {
Namespace = "󰌗",
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 = "󰊄",
Table = "",
Object = "󰅩",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "󰟢",
String = "󰉿",
Calendar = "",
Watch = "󰥔",
Package = "",
Copilot = "",
Codeium = "",
TabNine = "",
}
2023-08-20 22:09:00 +00:00
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
2023-08-22 14:51:35 +00:00
"L3MON4D3/LuaSnip",
2023-08-20 22:09:00 +00:00
},
config = function()
local cmp = require("cmp")
2023-08-22 14:51:35 +00:00
local opts = {
completion = {
completeopt = "menu,menuone,noinsert",
},
formatting = {
fields = { "abbr", "kind", "menu" },
format = function(_, item)
local icon = icons[item.kind] or ""
item.kind = string.format(" %s %s", icon, item.kind)
return item
end,
},
2023-08-20 22:09:00 +00:00
mapping = {
["<C-space>"] = cmp.mapping.complete(),
2023-08-22 14:51:35 +00:00
["<C-up>"] = cmp.mapping.select_prev_item(),
["<C-down>"] = cmp.mapping.select_next_item(),
["<C-e>"] = cmp.mapping.abort(),
2023-08-20 22:09:00 +00:00
["<cr>"] = cmp.mapping.confirm({ select = true }),
},
2023-08-22 14:51:35 +00:00
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
2023-08-20 22:09:00 +00:00
sources = {
{ name = "nvim_lsp" },
2023-08-22 14:51:35 +00:00
{ name = "luasnip" },
2023-08-20 22:09:00 +00:00
{ name = "buffer" },
{ name = "path" },
},
2023-08-22 14:51:35 +00:00
window = {
completion = {
border = "rounded",
scrollbar = false
},
documentation = {
border = "rounded",
}
},
}
cmp.setup(opts)
2023-08-20 22:09:00 +00:00
end,
}