From ac740e1f898798ce570e78f50f38a7b05959002f Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Sun, 13 Oct 2024 09:35:58 +0200 Subject: [PATCH 1/2] new version number and improved code so that there will be no trigger that often --- package.json | 12 ++++++------ src/extension.ts | 39 +-------------------------------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index a3c4aef..be9d660 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fabelous-autocoder", - "version": "0.2.0", + "version": "0.2.1", "displayName": "Fabelous Autocoder", "description": "A simple to use Ollama autocompletion Plugin", "icon": "icon.png", @@ -66,11 +66,6 @@ "default": 2000, "description": "The size of the prompt in characters. NOT tokens, so can be set about 1.5-2x the max tokens of the model (varies)." }, - "fabelous-autocoder.completion keys": { - "type": "string", - "default": " ", - "description": "Character that the autocompletion item provider appear on. Multiple characters will be treated as different entries. REQUIRES RELOAD" - }, "fabelous-autocoder.response preview": { "type": "boolean", "default": true, @@ -123,6 +118,11 @@ "command": "fabelous-autocoder.handleBackspace", "key": "backspace", "when": "editorTextFocus" + }, + { + "key": "alt+oem_plus", + "command": "fabelous-autocoder.autocomplete", + "when": "editorTextFocus" } ], "commands": [ diff --git a/src/extension.ts b/src/extension.ts index 0bbacc8..0802576 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -275,54 +275,17 @@ async function handleBackspace() { } } -async function provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, cancellationToken: vscode.CancellationToken) { - const item = new vscode.CompletionItem('Fabelous autocompletion'); - item.insertText = new vscode.SnippetString('${1:}'); - item.documentation = new vscode.MarkdownString('Press `Enter` to get an autocompletion from Fabelous Autocoder'); - if (config.responsePreview) { - await new Promise(resolve => setTimeout(resolve, config.responsePreviewDelay * 1000)); - if (cancellationToken.isCancellationRequested) { - return [item]; - } - - const context = getContextLines(document, position); - const fimPrompt = createFIMPrompt(context, document.languageId); - - try { - const result = await generateCompletion(fimPrompt, cancellationToken); - const preview = (result as any).preview; - if (preview) { - item.detail = preview.split('\n')[0]; - } - } catch (error) { - console.error('Error fetching preview:', error); - } - } - - if (config.continueInline || !config.responsePreview) { - item.command = { - command: 'fabelous-autocoder.autocomplete', - title: 'Fabelous Autocomplete', - arguments: [] - }; - } - - return [item]; -} export function activate(context: vscode.ExtensionContext) { updateConfig(); createPreviewDecorationType(); context.subscriptions.push( vscode.workspace.onDidChangeConfiguration(updateConfig), - vscode.languages.registerCompletionItemProvider('*', { provideCompletionItems }, ...config.completionKeys), vscode.commands.registerTextEditorCommand('fabelous-autocoder.autocomplete', autocompleteCommand), vscode.commands.registerCommand('fabelous-autocoder.handleTab', handleTab), - vscode.commands.registerCommand('fabelous-autocoder.handleBackspace', handleBackspace) // Add this line + vscode.commands.registerCommand('fabelous-autocoder.handleBackspace', handleBackspace) ); } - - export function deactivate() {} -- 2.34.1 From bf6318965b8ae0c5b7b6d652d363b2571561f0b1 Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Wed, 16 Oct 2024 12:37:40 +0200 Subject: [PATCH 2/2] updated readme for version 0.2.1 --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2efa36..2e76f9f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Fabelous Autocoder is a powerful VS Code extension that provides intelligent cod ## How It Works -1. Trigger the autocompletion by typing a completion key (configurable, default is space). +1. Trigger the autocompletion by typing the completion key (alt+oem_plus). 2. The extension sends your current code context to the configured API. 3. A code completion is generated and displayed as a preview. 4. Accept the completion with `Tab` or decline it with `Backspace`. @@ -21,7 +21,7 @@ Fabelous Autocoder is a powerful VS Code extension that provides intelligent cod ![Fabelous Autocoder Showcase](demo.gif) -1. **Trigger Completion**: Type normally and hit the completion key (space by default). +1. **Trigger Completion**: Type normally and hit the completion key (alt+oem_plus). 2. **Preview**: The suggested completion appears in light gray text. 3. **Accept**: Press `Tab` to accept the entire suggestion. 4. **Decline**: Press `Backspace` to remove the preview and decline the suggestion. @@ -36,7 +36,6 @@ Customize Fabelous Autocoder through VS Code settings: - `fabelous-autocoder.temperature`: Control the randomness of completions. - `fabelous-autocoder.max tokens predicted`: Set the maximum length of completions. - `fabelous-autocoder.prompt window size`: Adjust the context window size. -- `fabelous-autocoder.completion keys`: Set custom completion trigger keys. - `fabelous-autocoder.response preview`: Toggle preview functionality. - `fabelous-autocoder.preview max tokens`: Limit preview length. - `fabelous-autocoder.preview delay`: Add delay before showing preview. -- 2.34.1