Skip to content

Commit 174a537

Browse files
authored
Fix/134 filetype configuration: decouple names parser color_map namespaces (#136)
* ref: rename opts parameter to ud_opts to indicate that it is user_default_options table * feat(names parser): store color names matcher configurations as separate namespaces in color_map * doc: generate luadoc * ref(trie): check if children ndoes are nil before attempting to free memory * doc: converts luadoc comments to block format * ref: names_custom is expanded in config validation if user provided it as a function * ref: generate hash key for custom names table * feat: names_custom colormap tables are retrieved by hash key * ref: calculate hash for custom_names during config validation, store in new key `custom_names_hashed` * perf: use bitmask to track namespace state instead of using next * test: adds names_custom tests which were used to fix #134
1 parent 86c9a6a commit 174a537

36 files changed

+898
-543
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
- [Trie](#trie)
2121
- [Test](#test)
2222
- [Benchmark](#benchmark)
23-
- [Results](#results)
2423
- [Extras](#extras)
2524
- [TODO](#todo)
2625
<!--toc:end-->
@@ -135,8 +134,8 @@ library to do custom highlighting themselves.
135134
},
136135
-- Expects a table of color name to #RRGGBB value pairs. # is optional
137136
-- Example: { cool = "#107dac", ["notcool"] = "ee9240" }
138-
-- Set to false|nil to disable, for example when setting filetype options
139-
names_custom = false, -- Custom names to be highlighted: table|function|false|nil
137+
-- Set to false to disable, for example when setting filetype options
138+
names_custom = false, -- Custom names to be highlighted: table|function|false
140139
RGB = true, -- #RGB hex codes
141140
RGBA = true, -- #RGBA hex codes
142141
RRGGBB = true, -- #RRGGBB hex codes
@@ -229,6 +228,7 @@ require("colorizer").setup({
229228
})
230229

231230
-- Apply names_custom from theme
231+
-- names_custom are stored by hashed key to allow filetype to override `user_default_options`
232232
require("colorizer").setup({
233233
names = true,
234234
names_custom = function()
@@ -430,8 +430,6 @@ make trie-benchmark
430430
scripts/trie-benchmark.sh
431431
```
432432

433-
##### Results
434-
435433
Inserting 7245 words: using uppercase, lowercase, camelcase from `vim.api.nvim_get_color_map()` and Tailwind colors
436434

437435
| Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |

0 commit comments

Comments
 (0)