Skip to content

Commit

Permalink
Merge pull request #42 from selemondev/feat/snippets
Browse files Browse the repository at this point in the history
feat: configure shadcn-svelte-5 help and import snippets
  • Loading branch information
selemondev authored Oct 31, 2024
2 parents 35c3b9f + 342d7d8 commit c13c8be
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 8 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
**/.vscode-test.*
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to the "vscode-shadcn-svelte" extension will be documented i

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## v0.1.13

[compare changes](https://github.com/selemondev/vscode-shadcn-svelte/compare/v0.1.12...v0.1.13)

### 💅 Refactors

- Use esbuild instead of tsup ([341f8d6](https://github.com/selemondev/vscode-shadcn-svelte/commit/341f8d6))

### ❤️ Contributors

- Selemondev <[email protected]>

## v0.1.12

[compare changes](https://github.com/selemondev/vscode-shadcn-svelte/compare/v0.1.11...v0.1.12)
Expand Down
73 changes: 72 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-shadcn-svelte",
"version": "0.1.12",
"version": "0.1.13",
"displayName": "shadcn/svelte",
"description": "Integrate components and snippets from Shadcn/Svelte directly into your IDE ✨.",
"publisher": "Selemondev",
Expand Down Expand Up @@ -34,6 +34,77 @@
"activationEvents": [],
"main": "./dist/extension.js",
"contributes": {
"languages": [
{
"id": "svelte",
"aliases": [
"Svelte",
"Svelte 3",
"svelte"
],
"filenamePatterns": [
"*.svelte"
]
}
],
"snippets": [
{
"language": "javascript",
"path": "./src/snippets/imports-code-snippets.json"
},
{
"language": "typescript",
"path": "./src/snippets/imports-code-snippets.json"
},
{
"language": "javascript",
"path": "./src/snippets/imports-code-snippets-next.json"
},
{
"language": "typescript",
"path": "./src/snippets/imports-code-snippets-next.json"
},
{
"language": "javascript",
"path": "./src/snippets/help-code-snippets.json"
},
{
"language": "typescript",
"path": "./src/snippets/help-code-snippets.json"
},
{
"language": "javascript",
"path": "./src/snippets/help-code-snippets-next.json"
},
{
"language": "typescript",
"path": "./src/snippets/help-code-snippets-next.json"
},
{
"language": "html",
"path": "./src/snippets/help-code-snippets.json"
},
{
"language": "svelte",
"path": "./src/snippets/help-code-snippets.json"
},
{
"language": "html",
"path": "./src/snippets/help-code-snippets-next.json"
},
{
"language": "svelte",
"path": "./src/snippets/help-code-snippets-next.json"
},
{
"language": "html",
"path": "./src/snippets/usage-code-snippets.json"
},
{
"language": "svelte",
"path": "./src/snippets/usage-code-snippets.json"
}
],
"commands": [
{
"command": "shadcn-svelte.initCli",
Expand Down
19 changes: 12 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ const commands = {
} as const;

export async function activate(context: vscode.ExtensionContext) {
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
vscode.window.showErrorMessage("No workspace folder open.");
return;
}

let registryData: Components;

const disposables: vscode.Disposable[] = [
vscode.commands.registerCommand("shadcn-svelte.initCli", async () => {
vscode.commands.registerCommand(commands.initCli, async () => {
const intCmd = await getInitCmd();
executeCommand(intCmd);
}),
vscode.commands.registerCommand("shadcn-svelte.addNewComponent", async () => {
vscode.commands.registerCommand(commands.addNewComponent, async () => {
registryData = [];
const newRegistryData = await getRegistry();

Expand All @@ -49,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) {
executeCommand(installCmd);
}),

vscode.commands.registerCommand("shadcn-svelte.addMultipleComponents", async () => {
vscode.commands.registerCommand(commands.addMultipleComponents, async () => {
registryData = [];
const newRegistryData = await getRegistry();

Expand All @@ -74,7 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {
const installCmd = await getInstallCmd(selectedComponent);
executeCommand(installCmd);
}),
vscode.commands.registerCommand("shadcn-svelte.gotoComponentDoc", async () => {
vscode.commands.registerCommand(commands.gotoComponentDoc, async () => {
registryData = [];
const newRegistryData = await getRegistry();

Expand All @@ -96,7 +101,7 @@ export async function activate(context: vscode.ExtensionContext) {
const componentDocLink = await getComponentDocLink(selectedComponent.label);
vscode.env.openExternal(vscode.Uri.parse(componentDocLink));
}),
vscode.commands.registerCommand("shadcn-svelte.reloadComponentList", async () => {
vscode.commands.registerCommand(commands.reloadComponentList, async () => {
registryData = [];
const newRegistryData = await getRegistry();

Expand All @@ -108,7 +113,7 @@ export async function activate(context: vscode.ExtensionContext) {
registryData = newRegistryData;
vscode.window.showInformationMessage("shadcn/svelte: Reloaded components");
}),
vscode.commands.registerCommand("shadcn-svelte.gotoDoc", async () => {
vscode.commands.registerCommand(commands.gotoDoc, async () => {
const svelteVersion = await getSvelteVersion();
const shadCnDocUrl = svelteVersion >= 5 ? "https://next.shadcn-svelte.com/docs" : "https://shadcn-svelte.com/docs";
vscode.env.openExternal(vscode.Uri.parse(shadCnDocUrl));
Expand All @@ -119,4 +124,4 @@ export async function activate(context: vscode.ExtensionContext) {
}

// This method is called when your extension is deactivated
export function deactivate() { }
export function deactivate() { }

0 comments on commit c13c8be

Please sign in to comment.