Skip to content

Commit

Permalink
Fix/134 filetype configuration: decouple names parser color_map names…
Browse files Browse the repository at this point in the history
…paces (#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
  • Loading branch information
catgoose authored Jan 19, 2025
1 parent 86c9a6a commit 174a537
Show file tree
Hide file tree
Showing 36 changed files with 898 additions and 543 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
- [Trie](#trie)
- [Test](#test)
- [Benchmark](#benchmark)
- [Results](#results)
- [Extras](#extras)
- [TODO](#todo)
<!--toc:end-->
Expand Down Expand Up @@ -135,8 +134,8 @@ library to do custom highlighting themselves.
},
-- Expects a table of color name to #RRGGBB value pairs. # is optional
-- Example: { cool = "#107dac", ["notcool"] = "ee9240" }
-- Set to false|nil to disable, for example when setting filetype options
names_custom = false, -- Custom names to be highlighted: table|function|false|nil
-- Set to false to disable, for example when setting filetype options
names_custom = false, -- Custom names to be highlighted: table|function|false
RGB = true, -- #RGB hex codes
RGBA = true, -- #RGBA hex codes
RRGGBB = true, -- #RRGGBB hex codes
Expand Down Expand Up @@ -229,6 +228,7 @@ require("colorizer").setup({
})

-- Apply names_custom from theme
-- names_custom are stored by hashed key to allow filetype to override `user_default_options`
require("colorizer").setup({
names = true,
names_custom = function()
Expand Down Expand Up @@ -430,8 +430,6 @@ make trie-benchmark
scripts/trie-benchmark.sh
```

##### Results

Inserting 7245 words: using uppercase, lowercase, camelcase from `vim.api.nvim_get_color_map()` and Tailwind colors

| Initial Capacity | Resize Count | Insert Time (ms) | Lookup Time (ms) |
Expand Down
Loading

0 comments on commit 174a537

Please sign in to comment.