diff options
author | Akianonymus <anonymus.aki@gmail.com> | 2022-09-04 18:32:02 +0530 |
---|---|---|
committer | Akianonymus <anonymus.aki@gmail.com> | 2022-09-06 15:06:14 +0530 |
commit | 5f7680e7e7ccad68bd9962bcbb40dfde1c3669a1 (patch) | |
tree | 0345c3393e3f64d77042224dc6b3e4672b1e901e /lua/colorizer/trie.lua | |
parent | colorizer: Make sure it works without giving any config (diff) |
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
Diffstat (limited to 'lua/colorizer/trie.lua')
-rw-r--r-- | lua/colorizer/trie.lua | 17 |
1 files changed, 11 insertions, 6 deletions
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 |