From 5f7680e7e7ccad68bd9962bcbb40dfde1c3669a1 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sun, 4 Sep 2022 18:32:02 +0530 Subject: Fix https://github.com/NvChad/nvim-colorizer.lua/issues/12 | Add support for tailwind colors Three methods normal: Use the hardcoded colors lsp: Use lsp to fetch colors both: Use the hardcoded colors and use lsp too if available although this is hardcoding, but working with what we got, has all the colors tailwind provides, atleast the prebuilt ones for new defined colors, have to enable the lsp method Generated using https://github.com/tailwindlabs/tailwindcss/raw/master/src/public/colors.js and https://github.com/tailwindlabs/tailwindcss/raw/master/src/corePlugins.js use a different namespace than default for tailwind lsp method only try to use lsp method if attached Misc changes export the user_default_settings to doc clear name space after the lines are processed for a smooth transition cleanup some code --- lua/colorizer/trie.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lua/colorizer/trie.lua') diff --git a/lua/colorizer/trie.lua b/lua/colorizer/trie.lua index 82a0d2d..1f7a0de 100644 --- a/lua/colorizer/trie.lua +++ b/lua/colorizer/trie.lua @@ -55,13 +55,18 @@ local INDEX_LOOKUP_TABLE = ffi.new("uint8_t[?]", total_char) local CHAR_LOOKUP_TABLE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" do local b = string.byte + local extra_char = { + [b "-"] = true, + } + local byte = { ["0"] = b "0", ["9"] = b "9", ["a"] = b "a", ["A"] = b "A", ["z"] = b "z", ["Z"] = b "Z" } for i = 0, total_char do - if i >= b "0" and i <= b "9" then - INDEX_LOOKUP_TABLE[i] = i - b "0" - elseif i >= b "A" and i <= b "Z" then - INDEX_LOOKUP_TABLE[i] = i - b "A" + 10 - elseif i >= b "a" and i <= b "z" then - INDEX_LOOKUP_TABLE[i] = i - b "a" + 10 + 26 + if i >= byte["0"] and i <= byte["9"] then + INDEX_LOOKUP_TABLE[i] = i - byte["0"] + elseif i >= byte["A"] and i <= byte["Z"] then + INDEX_LOOKUP_TABLE[i] = i - byte["A"] + 10 + elseif i >= byte["a"] and i <= byte["z"] then + INDEX_LOOKUP_TABLE[i] = i - byte["a"] + 10 + 26 + elseif extra_char[i] then else INDEX_LOOKUP_TABLE[i] = total_char end -- cgit v1.2.3-70-g09d2