luckasRanarison / tailwind-tools.nvim

An unofficial Tailwind CSS integration and tooling for Neovim
https://dotfyle.com/plugins/luckasRanarison/tailwind-tools.nvim
MIT License
356 stars 15 forks source link

Add regex fallback #26

Closed luckasRanarison closed 2 months ago

luckasRanarison commented 4 months ago

Add the ability to use regex when classes cannot be obtained through treesitter. (#25)

It's currently blocked due to the lack of APIs for searching pattern and retrieving both start and end positions.

Confuze commented 3 months ago

This would be really helpful for already supported languages too. For example, when using tailwind with clsx, the plugin doesn't detect tailwind classes inside of the clsx() function. I used the following configuration to enable the lsp for clsx and would love to be able to do something similar here.

require'lspconfig'.tailwindcss.setup{
  -- ...
  settings = {
    experimental = {
      classRegex = { "clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)" }, -- regex taken from https://www.npmjs.com/package/clsx#tailwind-support
    }
  }
  -- ...
}
luckasRanarison commented 2 months ago

@Confuze Sorry for the late reply.

Lua patterns have been introduced in #31. Although your use case can be implemented using plain treesitter queries.

I'll make a list of css class libraries like clsx and add them directly to the plugin. But for the moment, I've shown an example using Lua patterns for capturing clsx in the updated README :)

luckasRanarison commented 2 months ago

update: clsx support has been added.