Skip to content

Commit

Permalink
add skip language snippets toggle to the snippets tree view (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomFractals committed Mar 31, 2021
1 parent 4d3ed3c commit 362c108
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
},
"activationEvents": [
"onCommand:snippets.viewer.combineLanguageSnippets",
"onCommand:snippets.viewer.skipLanguageSnippets",
"onCommand:snippets.viewer.groupSnippetsByFile",
"onCommand:snippets.viewer.refreshSnippets",
"onCommand:snippets.viewer.sortSnippetsByName",
"onCommand:snippets.viewer.sortSnippetsByDefinitionOrder",
"onCommand:snippets.viewer.refreshSnippets",
"onCommand:snippets.viewer.openSnippetFile",
"onCommand:snippets.viewer.insertSnippet",
"onCommand:snippets.viewer.viewSettings",
Expand All @@ -60,6 +61,12 @@
"category": "Snippets Viewer",
"icon": "$(chevron-down)"
},
{
"command": "snippets.viewer.skipLanguageSnippets",
"title": "Skip Language Snippets",
"category": "Snippets Viewer",
"icon": "$(filter)"
},
{
"command": "snippets.viewer.groupSnippetsByFile",
"title": "Group Snippets by File",
Expand Down Expand Up @@ -125,6 +132,11 @@
"when": "view == snippets.view",
"group": "navigation"
},
{
"command": "snippets.viewer.skipLanguageSnippets",
"when": "view == snippets.view",
"group": "navigation"
},
{
"command": "snippets.viewer.refreshSnippets",
"when": "view == snippets.view",
Expand Down Expand Up @@ -184,27 +196,27 @@
"snippets.viewer.showBuiltInExtensionSnippets": {
"type": "boolean",
"default": true,
"description": "Show built-in language extension snippets in Snippets tree view."
"description": "Show built-in language extension snippets in the Snippets tree view."
},
"snippets.viewer.skipLanguageSnippets": {
"type": "string",
"default": "",
"description": "Comma delimited list of languages to skip snippets display in Snippets tree view."
"description": "Comma delimited list of languages to skip snippets display in the Snippets tree view."
},
"snippets.viewer.combineLanguageSnippets": {
"type": "boolean",
"default": false,
"description": "Combine language snippets in Snippets tree view."
"description": "Combine language snippets in the Snippets tree view."
},
"snippets.viewer.expendSnippetFiles": {
"type": "boolean",
"default": false,
"description": "Expend snippet files on snippet language tree node expend in Snippets tree view."
"description": "Expend snippet files on snippet language tree node expend in the Snippets tree view."
},
"snippets.viewer.sortSnippetsByName": {
"type": "boolean",
"default": false,
"description": "Sort loaded snippets by name in Snippets tree view."
"description": "Sort loaded snippets by name in the Snippets tree view."
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export function registerCommands(context: ExtensionContext, snippetProvider: Sni
})
);

context.subscriptions.push(
commands.registerCommand(`snippets.viewer.skipLanguageSnippets`, () => {
commands.executeCommand('workbench.action.openSettings', 'snippets.viewer.skipLanguageSnippets');
})
);

context.subscriptions.push(
commands.registerCommand(`snippets.viewer.viewSettings`, () => {
commands.executeCommand('workbench.action.openSettings', 'snippets.viewer');
})
);

context.subscriptions.push(
commands.registerCommand(`snippets.viewer.insertSnippet`, (snippetBody: string | string[]) => {
let snippetAsString;
Expand Down Expand Up @@ -81,14 +93,6 @@ export function registerCommands(context: ExtensionContext, snippetProvider: Sni
});
})
);

context.subscriptions.push(
commands.registerCommand(`snippets.viewer.viewSettings`, viewSettings)
);
}

async function viewSettings() {
commands.executeCommand( 'workbench.action.openSettings', 'snippets.viewer' );
}

async function goToSymbol(document: TextDocument, symbolName: string) {
Expand Down

0 comments on commit 362c108

Please sign in to comment.