laytan / tailwind-sorter.nvim

Easily sort Tailwind classes in Neovim.
MIT License
134 stars 11 forks source link

How to sort file with different extension (e.g.heex ) ? #9

Closed collegeimprovements closed 1 year ago

collegeimprovements commented 1 year ago

Hi @laytan

Thanks a lot for this plugin. It's the missing piece.

We have a lot of files with filename.html.heex extension. And we want to sort tailwind classes in them. Is it possible with the help of neovim and this plugin ?

Our lazy-nvim is setup is as following:

return {
    "laytan/tailwind-sorter.nvim",
    dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-lua/plenary.nvim" },
    build = "cd formatter && npm i && npm run build",
    config = function()
        require("tailwind-sorter").setup({
            on_save_enabled = true, -- If `true`, automatically enables on save sorting.
            on_save_pattern = { "*.heex", "*.html", "*.js", "*.jsx", "*.tsx", "*.twig", "*.hbs", "*.php" }, -- The file patterns to watch and sort.
            node_path = "node",
        })
    end,
}

We even tried running TailwindSort command from the ex mode but it doesn't work either. The command is available but it doesn't format the file and doesn't sort the classes.

If we change the filetype to html by set ft=html then it works fine. But that would break few other things for us.

If possible, how to run it on files with heex extension or eelixir as filetype ?

collegeimprovements commented 1 year ago

I was able to make it work with null-ls and hence closing this issue.

laytan commented 1 year ago

Hey, even though you closed this, I added support for elixir and heex in #10 and your snippet of config would work with this version.