13
13
- [ Why another highlighter?] ( #why-another-highlighter )
14
14
- [ Customization] ( #customization )
15
15
- [ Updating color even when buffer is not focused] ( #updating-color-even-when-buffer-is-not-focused )
16
+ - [ Tailwind] ( #tailwind )
16
17
- [ Testing] ( #testing )
17
18
- [ Extras] ( #extras )
18
19
- [ TODO] ( #todo )
19
- - [ Similar projects] ( #similar-projects )
20
20
<!-- toc:end-->
21
21
22
22
[ ![ luadoc] ( https://img.shields.io/badge/luadoc-0.1-blue )] ( https://catgoose.github.io/nvim-colorizer.lua/ )
@@ -27,15 +27,11 @@ dependencies**! Written in performant Luajit.
27
27
As long as you have ` malloc() ` and ` free() ` on your system, this will work.
28
28
Which includes Linux, OSX, and Windows.
29
29
30
- ![ Demo.gif] ( https://raw.githubusercontent. com/norcalli/github-assets/master/ nvim-colorizer.lua- demo-short.gif )
30
+ ![ Demo.gif] ( https://github. com/catgoose/screenshots/blob/51466fa599efe6d9821715616106c1712aad00c3/ nvim-colorizer.lua/ demo-short.gif )
31
31
32
32
## Installation and Usage
33
33
34
34
Requires Neovim >= 0.7.0 and ` set termguicolors ` .
35
- If you don't have true color for your terminal or are
36
- unsure, [ read this excellent guide] ( https://github.com/termstandard/colors ) .
37
-
38
- Use your plugin manager or clone directly into your package.
39
35
40
36
### Plugin managers
41
37
@@ -58,33 +54,33 @@ use("catgoose/nvim-colorizer.lua")
58
54
59
55
#### Manual
60
56
61
- One line setup. This will create an ` autocmd ` for ` FileType * ` to highlight
62
- every filetype.
63
-
64
57
> [ !NOTE]
65
58
> You should add this line after/below where your plugins are setup.
66
59
67
60
``` lua
68
61
require (" colorizer" ).setup ()
69
62
```
70
63
64
+ This will create an ` autocmd ` for ` FileType * ` to highlight
65
+ every filetype.
66
+
71
67
### User commands
72
68
69
+ > [ !NOTE]
70
+ > User commands can be enabled/disabled in setup opts
71
+
73
72
| Command | Description |
74
73
| ----------------------------- | ----------------------------------------------------------- |
75
74
| ** ColorizerAttachToBuffer** | Attach to the current buffer with given or default settings |
76
75
| ** ColorizerDetachFromBuffer** | Stop highlighting the current buffer |
77
76
| ** ColorizerReloadAllBuffers** | Reload all buffers that are being highlighted currently |
78
77
| ** ColorizerToggle** | Toggle highlighting of the current buffer |
79
78
80
- > [ !NOTE]
81
- > User commands can be enabled/disabled in setup opts
82
-
83
79
### Lua API
84
80
85
81
``` lua
86
82
-- All options that can be passed to `user_default_options` in setup() can be
87
- -- passed here
83
+ -- passed to `attach_to_buffer`
88
84
-- Similar for other functions
89
85
90
86
-- Attach to buffer
@@ -107,10 +103,6 @@ is that _this only works for Neovim_, and that will never change.
107
103
Apart from that, it only applies the highlights to the current visible contents,
108
104
so even if a big file is opened, the editor won't just choke on a blank screen.
109
105
110
- This idea was copied from
111
- [ brenoprata10/nvim-highlight-colors] ( https://github.com/brenoprata10/nvim-highlight-colors )
112
- Credits to [ brenoprata10] ( https://github.com/brenoprata10 )
113
-
114
106
Additionally, having a Lua API that's available means users can use this as a
115
107
library to do custom highlighting themselves.
116
108
@@ -122,6 +114,10 @@ library to do custom highlighting themselves.
122
114
``` lua
123
115
require (" colorizer" ).setup ({
124
116
filetypes = { " *" },
117
+ -- all the sub-options of filetypes apply to buftypes
118
+ buftypes = {},
119
+ -- Boolean | List of usercommands to enable. See User commands section.
120
+ user_commands = true , -- Enable all or some usercommands
125
121
user_default_options = {
126
122
names = true , -- "Name" codes like Blue or red. Added from `vim.api.nvim_get_color_map()`
127
123
names_opts = { -- options for mutating/filtering names.
@@ -149,6 +145,9 @@ library to do custom highlighting themselves.
149
145
mode = " background" , -- Set the display mode
150
146
-- Tailwind colors. boolean|'normal'|'lsp'|'both'. True is same as normal
151
147
tailwind = false , -- Enable tailwind colors
148
+ tailwind_opts = { -- Options for highlighting tailwind names
149
+ update_names = false , -- When using tailwind = 'both', update tailwind names from LSP results. See tailwind section
150
+ },
152
151
-- parsers can contain values used in |user_default_options|
153
152
sass = { enable = false , parsers = { " css" } }, -- Enable sass colors
154
153
-- Virtualtext character to use
@@ -161,20 +160,18 @@ library to do custom highlighting themselves.
161
160
-- example use: cmp_menu, cmp_docs
162
161
always_update = false ,
163
162
},
164
- -- all the sub-options of filetypes apply to buftypes
165
- buftypes = {},
166
- -- Boolean | List of usercommands to enable
167
- user_commands = true , -- Enable all or some usercommands
168
163
})
169
164
```
170
165
171
- MODES :
166
+ Highlighting modes :
172
167
173
168
- ` background ` : sets the background text color.
174
169
- ` foreground ` : sets the foreground text color.
175
170
- ` virtualtext ` : indicate the color behind the virtualtext.
176
171
177
- For basic setup, you can use a command like the following.
172
+ Virtualtext symbol can be displayed at end of line, or
173
+
174
+ Setup examples:
178
175
179
176
``` lua
180
177
-- Attaches to every FileType with default options
@@ -260,9 +257,9 @@ In `user_default_options`, there are 2 types of options
260
257
261
258
1 . Alias options - ` css ` , ` css_fn `
262
259
263
- If ` css_fn ` is true, then ` hsl_fn ` , ` rgb_fn ` becomes ` true `
260
+ If ` css_fn ` is true ` hsl_fn ` , ` rgb_fn ` becomes ` true `
264
261
265
- If ` css ` is true, then ` names ` , ` RGB ` , ` RGBA ` , ` RRGGBB ` , ` RRGGBBAA ` , ` hsl_fn ` , ` rgb_fn `
262
+ If ` css ` is true ` names ` , ` RGB ` , ` RGBA ` , ` RRGGBB ` , ` RRGGBBAA ` , ` hsl_fn ` , ` rgb_fn `
266
263
becomes ` true `
267
264
268
265
These options have a priority, Individual options have the highest priority,
@@ -332,6 +329,38 @@ For lower level interface, see
332
329
[ LuaDocs for API details] ( https://catgoose.github.io/nvim-colorizer.lua/modules/colorizer.html )
333
330
or use ` :h colorizer ` once installed.
334
331
332
+ ### Tailwind
333
+
334
+ Tailwind colors can either be parsed from the Tailwind colors file (found in
335
+ ` lua/colorizer/data/tailwind_colors.lua ` ) or by requesting
336
+ ` textDocument/documentColor ` from the LSP.
337
+
338
+ When using ` tailwind="normal" ` , only standard color names/values are parsed.
339
+
340
+ Using the ` tailwind_opts.update_names ` configuration option, the ` tailwind_names `
341
+ color mapping will be updated with results from Tailwind LSP, including custom
342
+ colors defined in ` tailwind.config.{js,ts} ` .
343
+
344
+ This can be useful if you are highlighting ` cmp_menu ` filetype.
345
+
346
+ ``` typescript
347
+ // tailwind.config.ts
348
+ extend : {
349
+ colors : {
350
+ gray : {
351
+ 600 : ' #2CEF6F' ,
352
+ 700 : ' #AC50EF' ,
353
+ 800 : ' #2ECFF6' ,
354
+ },
355
+ },
356
+ },
357
+ ```
358
+
359
+ ![ tailwind.update_names] ( https://github.com/catgoose/screenshots/blob/51466fa599efe6d9821715616106c1712aad00c3/nvim-colorizer.lua/tailwind_update_names.png )
360
+
361
+ To improve highlighting performance with the slow Tailwind LSP, results from LSP
362
+ are cached and returned on ` WinScrolled ` event.
363
+
335
364
## Testing
336
365
337
366
For troubleshooting use ` test/minimal.lua ` .
@@ -350,7 +379,7 @@ to conveniently reattach Colorizer to `test/expect.lua` on save.
350
379
351
380
## Extras
352
381
353
- Documentaion is generated using ldoc. See
382
+ Documentation is generated using ldoc. See
354
383
[ scripts/gen_docs.sh] ( https://github.com/colorizer/nvim-colorizer.lua/blob/master/scripts/gen_docs.sh )
355
384
356
385
## TODO
@@ -359,7 +388,4 @@ Documentaion is generated using ldoc. See
359
388
- [ ] Add more display modes. E.g - sign column
360
389
- [ ] Use a more space efficient trie implementation.
361
390
- [ ] Support custom parsers
362
-
363
- ## Similar projects
364
-
365
- [ nvim-highlight-colors] ( https://github.com/brenoprata10/nvim-highlight-colors )
391
+ - [ ] Options support providing function to enable/disable instead of just boolean
0 commit comments