Skip to content

Commit

Permalink
feat: add support for more icon providers in cmp completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Jul 8, 2024
1 parent 024428b commit f633f03
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lua/astronvim/plugins/cmp_luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,26 @@ return {
if astro.is_available(source_plugin) then table.insert(sources, source) end
end

local format
local lspkind_avail, lspkind = pcall(require, "lspkind")
if lspkind_avail then format = lspkind.cmp_format(require("astrocore").plugin_opts "lspkind.nvim") end
local get_icon_provider = function()
local _, mini_icons = pcall(require, "mini.icons")
if _G.MiniIcons then return function(kind) return mini_icons.get("lsp", kind) end end
local lspkind_avail, lspkind = pcall(require, "lspkind")
if lspkind_avail then return function(kind) return lspkind.symbolic(kind, { mode = "symbol" }) end end
end
local icon_provider = get_icon_provider()

local format = function(entry, item)
local highlight_colors_avail, highlight_colors = pcall(require, "nvim-highlight-colors")
local color_item = highlight_colors_avail and highlight_colors.format(entry, { kind = item.kind })
if icon_provider then
local icon = icon_provider(item.kind)
if icon then item.kind = icon end
end
if color_item and color_item.abbr_hl_group then
item.kind, item.kind_hl_group = color_item.abbr, color_item.abbr_hl_group
end
return item
end

return {
enabled = function()
Expand Down

0 comments on commit f633f03

Please sign in to comment.