From 3e8a4e10920dc6431547035eec514cdd21e37a3a Mon Sep 17 00:00:00 2001 From: glepnir Date: Sat, 28 Feb 2026 23:02:52 +0800 Subject: feat(lsp): show color preview in completion items #32138 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Color completion items display as plain text without visual preview Solution: Parse RGB/hex colors from documentation and render with colored symbol ■ --- test/functional/plugin/lsp/completion_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/plugin') diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index 27d0de6cba..3f48ec4d91 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -171,6 +171,21 @@ describe('vim.lsp.completion: item conversion', function() eq(expected, got) end) + it('generate "■" symbol with highlight group for CompletionItemKind.Color', function() + local completion_list = { + { label = 'text-red-300', kind = 16, documentation = 'color: rgb(252, 165, 165)' }, + } + local result = complete('|', completion_list) + result = vim.tbl_map(function(x) + return { + word = x.word, + kind_hlgroup = x.kind_hlgroup, + kind = x.kind, + } + end, result.items) + eq({ { word = 'text-red-300', kind_hlgroup = '@lsp.color.fca5a5', kind = '■' } }, result) + end) + ---@param prefix string ---@param items lsp.CompletionItem[] ---@param expected table[] -- cgit