95 lines
3 KiB
Lua
95 lines
3 KiB
Lua
return {
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
version = false, -- last release is way too old
|
|
event = "InsertEnter",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
|
},
|
|
opts = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
return {
|
|
completion = {
|
|
completeopt = "menu,menuone,noinsert",
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
|
["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
["<C-j>"] = cmp.mapping(function(fallback)
|
|
if luasnip.expandable() then
|
|
luasnip.expand()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, {
|
|
"i",
|
|
"s",
|
|
}),
|
|
["<C-k>"] = cmp.mapping(function(fallback)
|
|
if luasnip.expand_or_jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, {
|
|
"i",
|
|
"s",
|
|
}),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "buffer" },
|
|
{ name = "path" },
|
|
}),
|
|
formatting = {
|
|
format = function(_, item)
|
|
local icons = require("lazyvim.config").icons.kinds
|
|
if icons[item.kind] then
|
|
item.kind = icons[item.kind] .. item.kind
|
|
end
|
|
return item
|
|
end,
|
|
},
|
|
experimental = {
|
|
ghost_text = {
|
|
hl_group = "LspCodeLens",
|
|
},
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
lazy = true,
|
|
dependencies = {
|
|
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
|
},
|
|
opts = function(_, opts)
|
|
local format_kinds = opts.formatting.format
|
|
opts.formatting.format = function(entry, item)
|
|
format_kinds(entry, item)
|
|
return require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
|
end
|
|
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
|
end,
|
|
},
|
|
}
|