steelsojka / headwind.nvim

MIT License
31 stars 3 forks source link

headwind.nvim

Port of the VSCode headwind plugin

This is still alpha level software... use with caution.

Install

-- Packer
use "steelsojka/headwind.nvim"

Setup

require "headwind".setup {
  -- options here
}

Options

sort_tailwind_class

A list that determines Headwind's defauls sort order

remove_duplicates

Headwind will remove duplicate class names by default. This can be toggled on or off. This defaults to true.

prepend_custom_classes

Headwind will append custom class names by default. They can be prepended instead. Defaults to false.

class_regex

Patterns to use for matching class strings. Note, this has no effect when using treesitter.

run_on_save

Headwind will run on save by default (if a tailwind.config.js file is present within your working directory). This can be toggled on or off. Defaults to true.

use_treesitter

Use treesitter to find class strings. This will be MUCH more accurate with a couple caveats...

Treesitter is ON by default. This method will be the primary supported method, since it is superior to regular pattern matching. If you have the correct treesitter parser installed then this flag just needs to be set to true. For more information on installing parsers look at the nvim-treesitter plugin.

Usage

Headwind doesn't do anything... you must call the API methods. This allows users to control when they want things to happen.

Api

buf_sort_tailwind_classes([bufnr], [opts])

Sorts all tailwind class matchers in the buffer and edits them in place.

visual_sort_tailwind_classes([opts])

Sorts all tailwind classes in the visual selection. Note, everything in the visual selection will be sorted as a class. This is useful for one off sorting.

string_sort_tailwind_classes([str], [opts])

Sorts the given tailwind class string and returns the result.