From 125e4995b86a94405aaf40191738f4b6fcd8ed57 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Wed, 7 Sep 2022 11:26:59 +0530 Subject: tailwind: Use true for normal mode For first start, wait 100 ms before trying to get some info from the lsp --- README.md | 3 ++- doc/colorizer.txt | 3 ++- doc/index.html | 2 +- doc/modules/colorizer.buffer_utils.html | 2 +- doc/modules/colorizer.color_utils.html | 2 +- doc/modules/colorizer.html | 5 +++-- doc/modules/colorizer.matcher_utils.html | 2 +- doc/modules/colorizer.trie.html | 2 +- doc/modules/utils.html | 2 +- lua/colorizer.lua | 5 +++-- lua/colorizer/buffer_utils.lua | 5 ++++- lua/colorizer/color_utils.lua | 2 +- lua/colorizer/matcher_utils.lua | 2 +- 13 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e5d46cc..1e9a510 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,8 @@ library to do custom highlighting themselves. css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn -- Available modes for `mode`: foreground, background, virtualtext mode = "background", -- Set the display mode. - -- Available methods are false / "normal" / "lsp" / "both" + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal tailwind = false -- Enable tailwind colors virtualtext = "■", }, diff --git a/doc/colorizer.txt b/doc/colorizer.txt index 5ac2abc..1ff8269 100644 --- a/doc/colorizer.txt +++ b/doc/colorizer.txt @@ -203,7 +203,8 @@ user_default_options *colorizer.user_default_options* css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn -- Available modes for `mode`: foreground, background, virtualtext mode = "background", -- Set the display mode. - -- Available methods are false / "normal" / "lsp" / "both" + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal tailwind = false -- Enable tailwind colors virtualtext = "■", } diff --git a/doc/index.html b/doc/index.html index 427033a..a14a7d8 100644 --- a/doc/index.html +++ b/doc/index.html @@ -77,7 +77,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/colorizer.buffer_utils.html b/doc/modules/colorizer.buffer_utils.html index 142164c..a25f6ef 100644 --- a/doc/modules/colorizer.buffer_utils.html +++ b/doc/modules/colorizer.buffer_utils.html @@ -231,7 +231,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/colorizer.color_utils.html b/doc/modules/colorizer.color_utils.html index 8cd68e2..522999c 100644 --- a/doc/modules/colorizer.color_utils.html +++ b/doc/modules/colorizer.color_utils.html @@ -351,7 +351,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/colorizer.html b/doc/modules/colorizer.html index e02633c..090c424 100644 --- a/doc/modules/colorizer.html +++ b/doc/modules/colorizer.html @@ -393,7 +393,8 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn -- Available modes for mode: foreground, background, virtualtext mode = "background", -- Set the display mode. - -- Available methods are false / "normal" / "lsp" / "both" + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal tailwind = false -- Enable tailwind colors virtualtext = "■", } @@ -477,7 +478,7 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/colorizer.matcher_utils.html b/doc/modules/colorizer.matcher_utils.html index e4cccee..7319be5 100644 --- a/doc/modules/colorizer.matcher_utils.html +++ b/doc/modules/colorizer.matcher_utils.html @@ -106,7 +106,7 @@ Do not try make the function again if it is present in the cache
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/colorizer.trie.html b/doc/modules/colorizer.trie.html index e2c7192..7f015f7 100644 --- a/doc/modules/colorizer.trie.html +++ b/doc/modules/colorizer.trie.html @@ -62,7 +62,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/doc/modules/utils.html b/doc/modules/utils.html index ffe7615..6651212 100644 --- a/doc/modules/utils.html +++ b/doc/modules/utils.html @@ -224,7 +224,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-06 15:06:04 +Last updated 2022-09-07 11:26:36
diff --git a/lua/colorizer.lua b/lua/colorizer.lua index f54f689..b1786d8 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -104,7 +104,8 @@ local BUFFER_LOCAL = {} -- css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn -- -- Available modes for `mode`: foreground, background, virtualtext -- mode = "background", -- Set the display mode. --- -- Available methods are false / "normal" / "lsp" / "both" +-- -- Available methods are false / true / "normal" / "lsp" / "both" +-- -- True is same as normal -- tailwind = false -- Enable tailwind colors -- virtualtext = "■", -- } @@ -133,7 +134,7 @@ local USER_DEFAULT_OPTIONS = { css = false, css_fn = false, mode = "background", - tailwind = "lsp", + tailwind = false, virtualtext = "■", } diff --git a/lua/colorizer/buffer_utils.lua b/lua/colorizer/buffer_utils.lua index 498804b..6feaadb 100644 --- a/lua/colorizer/buffer_utils.lua +++ b/lua/colorizer/buffer_utils.lua @@ -188,7 +188,10 @@ function highlight_buffer(buf, ns, lines, line_start, options, options_local) local ok, client = pcall(vim.lsp.get_client_by_id, args.data.client_id) if ok then if client.name == "tailwindcss" and client.supports_method "textDocument/documentColor" then - highlight_buffer_tailwind(buf, DEFAULT_NAMESPACE_TAILWIND, mode, options) + -- wait 100 ms for the first request + vim.defer_fn(function() + highlight_buffer_tailwind(buf, DEFAULT_NAMESPACE_TAILWIND, mode, options) + end, 100) TW_LSP_ATTACHED[buf] = true end end diff --git a/lua/colorizer/color_utils.lua b/lua/colorizer/color_utils.lua index b90c108..34a04f5 100644 --- a/lua/colorizer/color_utils.lua +++ b/lua/colorizer/color_utils.lua @@ -86,7 +86,7 @@ local function color_name_parser(line, i, opts) end end if opts and opts.tailwind then - if opts.tailwind == "normal" or opts.tailwind == "both" then + if opts.tailwind == true or opts.tailwind == "normal" or opts.tailwind == "both" then local tailwind = require "colorizer.tailwind_colors" -- setup tailwind colors for k, v in pairs(tailwind.colors) do diff --git a/lua/colorizer/matcher_utils.lua b/lua/colorizer/matcher_utils.lua index 11e56f6..29cd5e9 100644 --- a/lua/colorizer/matcher_utils.lua +++ b/lua/colorizer/matcher_utils.lua @@ -71,7 +71,7 @@ local function make_matcher(options) + (enable_AARRGGBB and 1 or 4) + (enable_rgb and 1 or 5) + (enable_hsl and 1 or 6) - + (enable_tailwind == "normal" and 1 or 7) + + ((enable_tailwind == true or enable_tailwind == "normal") and 1 or 7) + (enable_tailwind == "lsp" and 1 or 8) + (enable_tailwind == "both" and 1 or 9) -- cgit v1.2.3-70-g09d2