Skip to content

Commit

Permalink
feat: Show Item Kind in completion menu
Browse files Browse the repository at this point in the history
easy to identify

in tailwindcss, color properties show Color and rest are Constant
  • Loading branch information
Akianonymus committed Feb 24, 2023
1 parent 464e3df commit 32acef6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/cmp-tw2css/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,18 @@ end
---@return table<string, string> items
function source:get_sorted_items()
if not self.is_sorted then
local KIND = require("cmp").lsp.CompletionItemKind
-- if items table is not sorted, then sort it
self.items = require("cmp-tw2css.items")()
table.sort(self.items, function(a, b)
local kind = KIND.Constant
for _, val in ipairs({ "color", "stroke:", "fill:" }) do
if (a.insertText):match(val) then
kind = KIND.Color
break
end
end
a.kind = kind
return a.label < b.label
end)

Expand Down

0 comments on commit 32acef6

Please # to comment.