Skip to content

Commit ec6390b

Browse files
feat: sort on save
add option to sort classes on save
1 parent 86207e2 commit ec6390b

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@
165165
"type": "string",
166166
"default": "#AED0A4",
167167
"description": "Placeholder Color"
168+
},
169+
"windicss.runOnSave": {
170+
"type": "boolean",
171+
"default": true,
172+
"description": "A flag that controls whether or not Windi CSS classes will be sorted on save on save."
168173
}
169174
}
170175
}

src/extension.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { registerCompletions } from './lib/completions';
22
import { registerCommands } from './lib/commands';
33
import { registerCodeFolding } from './lib/folding';
44
import { init } from './lib/core';
5-
import { workspace } from 'vscode';
5+
import { commands, workspace } from 'vscode';
66
import type { Core } from './interfaces';
77
import type { ExtensionContext } from 'vscode';
88

@@ -32,6 +32,16 @@ export async function activate(ctx: ExtensionContext) {
3232
registerCompletions(ctx, CORE);
3333
registerCodeFolding(ctx);
3434
registerCommands(ctx, CORE);
35+
36+
// if runOnSave is enabled in settings, trigger command on file save
37+
if(workspace.getConfiguration().get('windicss.runOnSave')) {
38+
ctx.subscriptions.push(
39+
workspace.onDidSaveTextDocument((_e) => {
40+
commands.executeCommand('windicss.sort');
41+
})
42+
);
43+
}
44+
3545
console.log('Windi CSS Intellisense is now active!');
3646
}
3747

0 commit comments

Comments
 (0)