-
Notifications
You must be signed in to change notification settings - Fork 1
RubyMine, IntelliJ, PHPStorm, …
The File Watcher plugin allows calling the Tailwind sorter automatically upon saving a changed file.
-
Install the File Watchers plugin to the IDE.
-
Go to Tools ⟶ File Watchers section of the main Preferences and add a new File Watcher with the following settings:
- click the
"+"
symbol to add a new file watcher - name it e.g. "Tailwind Sorter"
- set the File type according to your needs; by default, Tailwind sorter supports Slim templates
- set the Scope to Project files so that changes in any relevant file across the whole project triggers the file watcher
- set the Program to the path to
tailwind_sorter
binstub, i.e.tailwind_sorter
if you have it accessible from$PATH
or$ProjectFileDir$/bin/tailwind_sorter
otherwise - set the Arguments to
$FilePath$
, i.e. to the name of the edited file - we recommend to un-check the checkboxes ”Auto-save the edited files to trigger the watcher“ and ”Trigger the watcher on external changes“ to prevent ”random“ run-loops in certain scenarios
- set the Show console parameter to ”On Error“; the ”Always“ option is helpful if you want to debug / develop the script itself
- confirm the dialog and check the ”Enable“ checkbox to actually set this file watcher ready
Now, whenever you make a change to any file conforming to the ”File type“ selection above and save the file, the file watcher triggers the Tailwind sorter ⟶ it reorders classes in the file inplace ⟶ the changes are automatically visible in the IDE GUI.
After the script is run on a changed file, sometimes the ctrl+z
(Undo) action does not work properly, since when you undo the changes, the script is immediately run again, redoing the changes. To fix this behavior, go to the main Settings ⟶ Appearance & Behavior ⟶ System Settings ⟶ the Autosave section ⟶ and un-check the "Save files when switching to a different application" checkbox.
The downside of this fix is that now the currently edited file is not auto-saved by the IDE whenever you switch to a different application.