Open bennypowers opened 2 years ago
To extend on @bennypowers nice explanation, here is an explicit example of installing and configuring vim-hexokinase
using the packer
startup
function:
use({
"RRethy/vim-hexokinase",
run = "make hexokinase",
setup = function()
vim.g.Hexokinase_highlighters = { "foregroundfull" }
end,
})
Note that you have to run :PackerSync
after changing the setup
function in order for changes in the configuration to be applied.
Thank you for publishing this helpful package 🙇
Please consider adding a lua configuration API for neovim users. A straw example of what I mean:
I've configured hexokinase to eat my project's design tokens.
Code to generate hexokinase
```js const isColorAlias = token => token.original?.value?.startsWith?.('{color.'); const pairAliasWithValue = token => { if (typeof token.value === 'string') { return [ [ token.original.value.replace(/\._}$/, '}'), token.value ] ]; } else if (token.value) { return Object.fromEntries(Object.entries(token.value).map(pairAliasWithValue)) } else { return [] } } /** * Exports [vim-hexokinase](https://github.com/RRethy/vim-hexokinase) custom patterns */ StyleDictionary.registerFormat({ name: 'editor/hexokinase', formatter: ({ dictionary }) => JSON.stringify({ regex_pattern: '\\{color\\.(\\w+)\.(\\d{1,3})\\}', colour_table: Object.fromEntries( dictionary.allTokens.filter(isColorAlias).flatMap(pairAliasWithValue)) }, null, 2), }); ```colour_table
Once built, I can load up the patterns via the vimscript global configuration keys:
This is fine, but as a user I'll need to make sure to set these prior to loading hexokinase. When using
packer.nvim
plugin manager, it's typical practice to configure plugins with a setup function after loading. I can work around this by using packer'ssetup
key, so nothing is blocked, but a lua API would be a drop more ergonomic for neovim users.Thanks for considering this request and thanks again for this nice package.