Skip to content

Commit

Permalink
Revert "fix: recover vueBase, not following file configuration (#163)"
Browse files Browse the repository at this point in the history
This reverts commit 317a3c8.
  • Loading branch information
adhamfarrag committed Sep 19, 2024
1 parent 7570d08 commit f0728d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ While using the CLI directly from your terminal is perfectly viable, Nuxtr's int

**Nuxt Snippets**: Enhance your development speed with Nuxt snippets. Simply type `nuxt` for components, `use` for Composables, or begin typing Nuxt utilities and select your desired snippet from the list.

Starting 0.2.10, you can inject a dynamic snippet based on your Nuxtr Vue files configuration with `vueBase` or `nuxtBaseLayout`.
Starting 0.2.10, you can inject a dynamic snippet based on your Nuxtr Vue files configuration with `vueBase` or `vueBaseLayout`.

Nuxt Snippets are enabled by default. You can toggle them on or off using this setting:

Expand Down
40 changes: 8 additions & 32 deletions src/snippets/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { homedir } from 'node:os';
import { resolve } from 'pathe';
import { readPackageJSON, writePackageJSON } from 'pkg-types';
import { CompletionItem, CompletionItemKind, MarkdownString, extensions, languages } from 'vscode';
import { generateVueFileTemplate } from '../utils';
import { resolve } from 'pathe';
import { readPackageJSON, writePackageJSON } from 'pkg-types'
import { homedir } from 'node:os';
import { generateVueFileBasicTemplate } from '../utils';

interface Snippet {
language: string;
Expand All @@ -17,9 +17,7 @@ export async function toggleSnippets(source: 'Nuxt' | 'Nitro', moveToDisabled: b

const extensionDir = resolve(homeDir, '.vscode', 'extensions', `${extensionName}-${nuxtrVersion}`);
const pkgJsonPath = resolve(extensionDir, 'package.json');

const pkgJSON = await readPackageJSON(extensionDir);

let snippets: Snippet[] = pkgJSON?.contributes?.snippets || [];
let disabledSnippets: Snippet[] = pkgJSON?.contributes?.disabled_snippets || [];

Expand Down Expand Up @@ -50,37 +48,15 @@ languages.registerCompletionItemProvider(
{ language: 'vue' },
{
provideCompletionItems() {
const completionItem = new CompletionItem('nuxtBaseLayout', CompletionItemKind.Snippet);
completionItem.detail = 'Generate a Nuxt Layout template';

const template = generateVueFileTemplate('layout');

const documentation = new MarkdownString();
documentation.appendMarkdown(`Generate a Nuxt layout template according to your Nuxtr configuration.\n\n`);
documentation.appendCodeblock(template, 'vue');

completionItem.documentation = documentation;
completionItem.kind = CompletionItemKind.Snippet;
completionItem.insertText = template;

return [completionItem];
}
}
);


languages.registerCompletionItemProvider(
{ language: 'vue' },
{
provideCompletionItems() {
const completionItem = new CompletionItem('vueBase', CompletionItemKind.Snippet);
const completionItem = new CompletionItem('vueBaseLayout', CompletionItemKind.Snippet);
completionItem.detail = 'Generate a Vue file template';

const template = generateVueFileTemplate('page');
const template = generateVueFileBasicTemplate('layout');

// Create a MarkdownString for documentation with code highlighting
const documentation = new MarkdownString();
documentation.appendMarkdown(`Generate a Vue file template according to your Nuxtr configuration.\n\n`);
documentation.appendCodeblock(template, 'vue');
documentation.appendCodeblock(template, 'vue'); // Specify 'vue' as the language for code block highlighting

completionItem.documentation = documentation;
completionItem.kind = CompletionItemKind.Snippet;
Expand Down

0 comments on commit f0728d7

Please sign in to comment.