Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laytan/tailwind-sorter.nvim
Easily sort Tailwind classes in Neovim.
https://github.com/laytan/tailwind-sorter.nvim
deno neovim tailwindcss
Last synced: 6 days ago
JSON representation
Easily sort Tailwind classes in Neovim.
- Host: GitHub
- URL: https://github.com/laytan/tailwind-sorter.nvim
- Owner: laytan
- License: mit
- Created: 2023-02-04T01:20:51.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-11T20:59:41.000Z (23 days ago)
- Last Synced: 2024-12-20T23:52:32.352Z (14 days ago)
- Topics: deno, neovim, tailwindcss
- Language: Lua
- Homepage:
- Size: 180 KB
- Stars: 143
- Watchers: 2
- Forks: 13
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tailwind Sorter for Neovim
Sorts your tailwind classes, just like
[prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss).The plugin integrates with Treesitter to find classes. This means it can work in
any language and is easy to extend to new file types.## Features
- Works in more file types than prettier does (using a treesitter integration),
confirmed to work with:
- jsx
- tsx
- html
- twig
- handlebars
- elixir/heex
- astro
- haskell
- any languages that inject any of the above languages
- Not having to pull in prettier just to have your classes sorted
- Easier/faster than prettier if all you want is tailwind sorting
- Easy to extend to other languages or use-cases## Usage
### Commands
- `:TailwindSort` sorts classes in the current buffer
- `:TailwindSortOnSaveToggle` toggles automatic sorting on save### Requirements
- NodeJS, tested with v16, v18 and v20
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- [plenary](https://github.com/nvim-lua/plenary.nvim)### Configuration
The following is the **default** configuration:
```lua
require('tailwind-sorter').setup({
on_save_enabled = false, -- If `true`, automatically enables on save sorting.
on_save_pattern = { '*.html', '*.js', '*.jsx', '*.tsx', '*.twig', '*.hbs', '*.php', '*.heex', '*.astro' }, -- The file patterns to watch and sort.
node_path = 'node',
trim_spaces = false, -- If `true`, trim any extra spaces after sorting.
})
```#### lazy.nvim
```lua
require('lazy').setup({
{
'laytan/tailwind-sorter.nvim',
dependencies = {'nvim-treesitter/nvim-treesitter', 'nvim-lua/plenary.nvim'},
build = 'cd formatter && npm ci && npm run build',
config = true,
},
})
```#### packer.nvim
```lua
require('packer').startup(function(use)
use {
'laytan/tailwind-sorter.nvim',
requires = {'nvim-treesitter/nvim-treesitter', 'nvim-lua/plenary.nvim'},
config = function() require('tailwind-sorter').setup() end,
run = 'cd formatter && npm ci && npm run build',
}
end)
```#### vim-plug
```vim
call plug#begin()Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-lua/plenary.nvim'
Plug 'laytan/tailwind-sorter.nvim', { 'do': 'cd formatter && npm ci && npm run build' }call plug#end()
lua <