16
16
- [ Lazyload Colorizer with Lazy.nvim] ( #lazyload-colorizer-with-lazynvim )
17
17
- [ Tailwind] ( #tailwind )
18
18
- [ Testing] ( #testing )
19
+ - [ Minimal Colorizer] ( #minimal-colorizer )
20
+ - [ Trie] ( #trie )
21
+ - [ Test] ( #test )
22
+ - [ Benchmark] ( #benchmark )
23
+ - [ Results] ( #results )
19
24
- [ Extras] ( #extras )
20
25
- [ TODO] ( #todo )
21
26
<!-- toc:end-->
@@ -114,10 +119,8 @@ library to do custom highlighting themselves.
114
119
115
120
``` lua
116
121
require (" colorizer" ).setup ({
117
- -- Filetype options. Accepts table like `user_default_options`
118
- filetypes = { " *" },
119
- -- Buftype options. Accepts table like `user_default_options`
120
- buftypes = {},
122
+ filetypes = { " *" }, -- Filetype options. Accepts table like `user_default_options`
123
+ buftypes = {}, -- Buftype options. Accepts table like `user_default_options`
121
124
-- Boolean | List of usercommands to enable. See User commands section.
122
125
user_commands = true , -- Enable all or some usercommands
123
126
lazy_load = false , -- Lazily schedule buffer highlighting setup function
@@ -144,19 +147,18 @@ library to do custom highlighting themselves.
144
147
css = false , -- Enable all CSS *features*:
145
148
-- names, RGB, RGBA, RRGGBB, RRGGBBAA, AARRGGBB, rgb_fn, hsl_fn
146
149
css_fn = false , -- Enable all CSS *functions*: rgb_fn, hsl_fn
147
- -- Highlighting mode. 'background'|'foreground'|'virtualtext'
148
- mode = " background" , -- Set the display mode
149
- -- Tailwind colors. boolean|'normal'|'lsp'|'both'. True is same as normal
150
+ -- Tailwind colors. boolean|'normal'|'lsp'|'both'. True sets to 'normal'
150
151
tailwind = false , -- Enable tailwind colors
151
152
tailwind_opts = { -- Options for highlighting tailwind names
152
- update_names = false , -- When using tailwind = 'both', update tailwind
153
- -- names from LSP results. See tailwind section
153
+ update_names = false , -- When using tailwind = 'both', update tailwind names from LSP results. See tailwind section
154
154
},
155
155
-- parsers can contain values used in `user_default_options`
156
156
sass = { enable = false , parsers = { " css" } }, -- Enable sass colors
157
+ -- Highlighting mode. 'background'|'foreground'|'virtualtext'
158
+ mode = " background" , -- Set the display mode
157
159
-- Virtualtext character to use
158
160
virtualtext = " ■" ,
159
- -- Display virtualtext inline with color
161
+ -- Display virtualtext inline with color. boolean|'before'|'after'. True sets to 'after'
160
162
virtualtext_inline = false ,
161
163
-- Virtualtext highlight mode: 'background'|'foreground'
162
164
virtualtext_mode = " foreground" ,
@@ -167,14 +169,6 @@ library to do custom highlighting themselves.
167
169
})
168
170
```
169
171
170
- Highlighting modes:
171
-
172
- - ` background ` : sets the background text color.
173
- - ` foreground ` : sets the foreground text color.
174
- - ` virtualtext ` : indicate the color behind the virtualtext.
175
-
176
- Virtualtext symbol can be displayed at end of line, or
177
-
178
172
Setup examples:
179
173
180
174
``` lua
@@ -379,20 +373,116 @@ are cached and returned on `WinScrolled` event.
379
373
380
374
## Testing
381
375
382
- For troubleshooting use ` test/minimal.lua ` .
383
- Startup neovim with ` nvim --clean -u minimal.lua ` in the ` test ` directory.
376
+ ### Minimal Colorizer
384
377
385
- Alternatively, use the following script from root directory:
378
+ For troubleshooting use ` test/minimal-colorizer.lua ` .
379
+ Startup neovim with ` nvim --clean -u minimal-colorizer.lua ` in the ` test ` directory.
380
+
381
+ Alternatively,
386
382
387
383
``` bash
388
- scripts/start_minimal.sh
384
+ make minimal
385
+ ```
386
+
387
+ or
388
+
389
+ ``` bash
390
+ scripts/minimal-colorizer.sh
389
391
```
390
392
391
393
To test colorization with your config, edit ` test/expect.lua ` to see expected
392
394
highlights.
393
395
The returned table of ` user_default_options ` from ` text/expect.lua ` will be used
394
396
to conveniently reattach Colorizer to ` test/expect.lua ` on save.
395
397
398
+ ### Trie
399
+
400
+ Colorizer uses a space efficient LuaJIT Trie implementation, which starts with
401
+ an initial node capacity of 8 bytes and expands capacity per node when needed.
402
+
403
+ The trie can be tested and benchmarked using ` test/trie/test.lua ` and
404
+ ` test/trie/benchmark.lua ` respectively.
405
+
406
+ #### Test
407
+
408
+ ``` bash
409
+ # runs both trie-test and trie-benchmark targets
410
+ make trie
411
+ ```
412
+
413
+ ``` bash
414
+ # runs trie test which inserts words and checks longest prefix
415
+ make trie-test
416
+ ```
417
+
418
+ #### Benchmark
419
+
420
+ ``` bash
421
+ scripts/trie-test.sh
422
+ ```
423
+
424
+ ``` bash
425
+ # runs benchmark for different node initial capacity allocation
426
+ make trie-benchmark
427
+ ```
428
+
429
+ ``` bash
430
+ scripts/trie-benchmark.sh
431
+ ```
432
+
433
+ ##### Results
434
+
435
+ Inserting 7245 words: using uppercase, lowercase, camelcase from ` vim.api.nvim_get_color_map() ` and Tailwind colors
436
+
437
+ | Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |
438
+ | ---------------- | ------------ | ---------------- | ---------------- |
439
+ | 1 | 3652 | 25 | 16 |
440
+ | 2 | 2056 | 11 | 8 |
441
+ | 4 | 1174 | 6 | 5 |
442
+ | 8 | 576 | 7 | 5 |
443
+ | 16 | 23 | 7 | 5 |
444
+ | 32 | 1 | 8 | 6 |
445
+ | 64 | 0 | 10 | 7 |
446
+
447
+ Inserting 1000 randomized words
448
+
449
+ | Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |
450
+ | ---------------- | ------------ | ---------------- | ---------------- |
451
+ | 1 | 434 | 1 | 0 |
452
+ | 2 | 234 | 1 | 1 |
453
+ | 4 | 129 | 1 | 0 |
454
+ | 8 | 51 | 1 | 0 |
455
+ | 16 | 17 | 1 | 1 |
456
+ | 32 | 3 | 1 | 2 |
457
+ | 64 | 1 | 2 | 1 |
458
+ | 128 | 0 | 4 | 1 |
459
+
460
+ Inserting 10,000 randomized words
461
+
462
+ | Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |
463
+ | ---------------- | ------------ | ---------------- | ---------------- |
464
+ | 1 | 4614 | 9 | 7 |
465
+ | 2 | 2106 | 8 | 8 |
466
+ | 4 | 842 | 9 | 7 |
467
+ | 8 | 362 | 9 | 8 |
468
+ | 16 | 208 | 11 | 9 |
469
+ | 32 | 113 | 14 | 11 |
470
+ | 64 | 24 | 21 | 14 |
471
+ | 128 | 0 | 34 | 25 |
472
+
473
+ Inserting 100,000 randomized words
474
+
475
+ | Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |
476
+ | ---------------- | ------------ | ---------------- | ---------------- |
477
+ | 1 | 40656 | 160 | 117 |
478
+ | 2 | 21367 | 116 | 111 |
479
+ | 4 | 11604 | 122 | 109 |
480
+ | 8 | 5549 | 133 | 113 |
481
+ | 16 | 1954 | 141 | 138 |
482
+ | 32 | 499 | 173 | 158 |
483
+ | 64 | 100 | 233 | 173 |
484
+ | 128 | 0 | 343 | 198 |
485
+
396
486
## Extras
397
487
398
488
Documentation is generated using ldoc. See
@@ -402,6 +492,5 @@ Documentation is generated using ldoc. See
402
492
403
493
- [ ] Add more color types ( var, advanced css functions )
404
494
- [ ] Add more display modes. E.g - sign column
405
- - [ ] Use a more space efficient trie implementation.
406
495
- [ ] Support custom parsers
407
496
- [ ] Options support providing function to enable/disable instead of just boolean
0 commit comments