From 6d87fbb90ae3bf7cfe64e7635532cdd76c1f7879 Mon Sep 17 00:00:00 2001 From: Pojok Code Date: Fri, 18 Jul 2025 22:23:07 +0700 Subject: [PATCH] enc: add colorfull cmp, add new simple icon, enhance odeium config --- lazy-lock.json | 11 +++--- lua/pcode/plugins/cmp.lua | 40 +++++++++++++++++---- lua/pcode/plugins/extras/neocodeium.lua | 46 ++++++++++++++++++++++++- lua/pcode/plugins/theme/dracula.lua | 1 + lua/pcode/user/icons.lua | 12 ++++--- 5 files changed, 93 insertions(+), 17 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 5e5aa7e..909c3f9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -16,15 +16,16 @@ "cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, + "colorful-menu.nvim": { "branch": "master", "commit": "bc3e82609f2fcf7dad7ca87c20e65e51d5d9d87c" }, "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "bbee149e00c404aa9f7a7c248b981cde953b252a" }, + "gitsigns.nvim": { "branch": "main", "commit": "0cb5a7753d3c4b8e9cfdc9d88d9110cb8d4b1544" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "acb2d97a5c5e3f58156cb387fdf6035c34cd2768" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a9c876d72d82b6640266f8b248ac05a63630b1d9" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, "neocodeium": { "branch": "main", "commit": "b4daf6805511681f83b37829e98f2d79418a93a6" }, @@ -33,7 +34,7 @@ "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, - "nvim-lspconfig": { "branch": "master", "commit": "d005da998edad401524504d03c7a88a56d125224" }, + "nvim-lspconfig": { "branch": "master", "commit": "d3934000788ab0a8f98ed58bc69e4b73ad26b110" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, @@ -43,8 +44,8 @@ "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, - "smart-splits.nvim": { "branch": "master", "commit": "30d645ed1eab77df9a5d9e98515316165b7d9ab9" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "5ebe9f26e0263ac724211e8637874df8ab9e7cc4" }, + "smart-splits.nvim": { "branch": "master", "commit": "c2744fd80d4735134f96f50acaccc4fa9f48d6cb" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, diff --git a/lua/pcode/plugins/cmp.lua b/lua/pcode/plugins/cmp.lua index 642b2ec..0df08c7 100644 --- a/lua/pcode/plugins/cmp.lua +++ b/lua/pcode/plugins/cmp.lua @@ -24,6 +24,7 @@ return { "hrsh7th/cmp-path", "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lua", + "xzbdmw/colorful-menu.nvim", }, opts = function() local cmp = require("cmp") @@ -90,13 +91,38 @@ return { format = function(entry, vim_item) vim_item.menu = vim.api.nvim_get_mode().mode == "c" and "" or all_trim(vim_item.kind) vim_item.kind = string.format("%s", all_trim(require("pcode.user.icons")["kind2"][vim_item.kind])) - -- vim_item.menu = ({ - -- nvim_lsp = "(LSP)", - -- luasnip = "(Snippet)", - -- buffer = "(Buffer)", - -- path = "(Path)", - -- codeium = "(Codeium)", - -- })[entry.source.name] + + local original_notify = vim.notify + vim.notify = function(msg, level, opts) + if type(msg) == "string" and msg:match("has new line character, please open an issue") then + return + end + original_notify(msg, level, opts) + end + + local ok, highlights_info = pcall(require("colorful-menu").cmp_highlights, entry) + if ok and highlights_info ~= nil then + vim_item.abbr_hl_group = highlights_info.highlights + + -- ambil nama group hilightnya saja + -- eg. "@parameter" + local var_hilight = highlights_info.highlights[1][1] + local id = vim.fn.hlID(var_hilight) + + local var_out = "@tag" + -- cek apakah hilight terdefinisi + if id ~= 0 then + var_out = var_hilight + else + var_out = var_hilight:match("([^%.]+)") + end + + vim_item.menu_hl_group = var_out + -- vim.notify(var_out) + else + vim_item.abbr_hl_group = "CmpItemAbbr" + vim_item.menu_hl_group = "CmpItemAbbr" + end return vim_item end, }, diff --git a/lua/pcode/plugins/extras/neocodeium.lua b/lua/pcode/plugins/extras/neocodeium.lua index 41ea435..edd67a9 100644 --- a/lua/pcode/plugins/extras/neocodeium.lua +++ b/lua/pcode/plugins/extras/neocodeium.lua @@ -2,8 +2,52 @@ return { "monkoose/neocodeium", event = "VeryLazy", config = function() + local uv = vim.uv + local fn = vim.fn + local pummenu_timer = assert(uv.new_timer()) + local cmp = require("cmp") local neocodeium = require("neocodeium") - neocodeium.setup() + local renderer = require("neocodeium.renderer") + local completer = require("neocodeium.completer") + local function is_noselect() + local completeopt = vim.o.completeopt + return completeopt:find("noselect") and -1 or 0 + end + + local default_selected_compl = is_noselect() + local selected_compl = default_selected_compl + + -- if cmp menu_opened then neocodeium clear + cmp.event:on("menu_opened", function() + neocodeium.clear() + end) + neocodeium.setup({ + filter = function() + return not cmp.visible() + end, + }) + + -- if cmp menu_is_closed then neocodeium activate + cmp.event:on("menu_closed", function() + local cur_selected = fn.complete_info({ "selected" }).selected + if selected_compl == cur_selected then + completer:initiate() + else + selected_compl = cur_selected + completer:clear(true) + renderer:display_label() + pummenu_timer:stop() + pummenu_timer:start( + 400, + 0, + vim.schedule_wrap(function() + if fn.pumvisible() == 1 then + completer:initiate() + end + end) + ) + end + end) vim.keymap.set("i", "", function() neocodeium.accept() end) diff --git a/lua/pcode/plugins/theme/dracula.lua b/lua/pcode/plugins/theme/dracula.lua index 8a370a6..babb414 100644 --- a/lua/pcode/plugins/theme/dracula.lua +++ b/lua/pcode/plugins/theme/dracula.lua @@ -25,6 +25,7 @@ return { ["@tag.css"] = { fg = colors.pink }, ["@keyword.css"] = { fg = colors.fg }, ["@string.css"] = { fg = colors.pink }, + ["@punctuation.delimiter.lua"] = { fg = colors.orange }, NvimTreeFolderIcon = { fg = "#6776a7" }, CmpItemAbbr = { fg = "#ABB2BF" }, CmpItemKind = { fg = "#ABB2BF" }, diff --git a/lua/pcode/user/icons.lua b/lua/pcode/user/icons.lua index b31639e..0659e2d 100644 --- a/lua/pcode/user/icons.lua +++ b/lua/pcode/user/icons.lua @@ -52,7 +52,8 @@ return { Color = " 󰰠 ", Control = "  ", Collapsed = " > ", - Constant = " 󰯱 ", + -- Constant = " 󰯱 ", + Constant = " 󰯲 ", Constructor = "  ", Copilot = "  ", Enum = " 󰯹 ", @@ -68,7 +69,8 @@ return { -- Keyword = " 󱕴 ", Keyword = "  ", Method = " 󰰑 ", - Module = " 󰆼 ", + -- Module = " 󰆼 ", + Module = " 󰰐 ", Namespace = " 󰰔 ", Null = "  ", Number = " 󰰔 ", @@ -78,12 +80,14 @@ return { Property = " 󰲽 ", Reference = " 󰰠 ", -- Snippet = "  ", - Snippet = "  ", + -- Snippet = "  ", + Snippet = " 󰰢 ", String = "  ", Struct = " 󰰣 ", TabNine = " 󰏚 ", -- Text = " 󱜥 ", - Text = "  ", + -- Text = "  ", + Text = " 󰰥 ", TypeParameter = " 󰰦 ", Unit = " 󱜥 ", Value = "  ",