diff --git a/.idx/dev.nix b/.idx/dev.nix new file mode 100644 index 00000000..83eb293f --- /dev/null +++ b/.idx/dev.nix @@ -0,0 +1,48 @@ +# Created for Void +# To learn more about how to use Nix to configure your environment +# see: https://developers.google.com/idx/guides/customize-idx-env +{pkgs}: { + # Which nixpkgs channel to use. + channel = "stable-23.11"; # or "unstable" + # Use https://search.nixos.org/packages to find packages + packages = [ + pkgs.nodejs_20 + pkgs.yarn + pkgs.nodePackages.pnpm + pkgs.bun + pkgs.gh + ]; + # Sets environment variables in the workspace + env = {}; + idx = { + # Search for the extensions you want on https://open-vsx.org/ and use "publisher.id" + extensions = [ + # "vscodevim.vim" + ]; + workspace = { + # Runs when a workspace is first created with this `dev.nix` file + onCreate = { + npm-install = "npm ci --no-audit --prefer-offline --no-progress --timing"; + # Open editors for the following files by default, if they exist: + default.openFiles = [ + # Cover all the variations of language, src-dir, router (app/pages) + "pages/index.tsx" "pages/index.jsx" + "src/pages/index.tsx" "src/pages/index.jsx" + "app/page.tsx" "app/page.jsx" + "src/app/page.tsx" "src/app/page.jsx" + ]; + }; + # To run something each time the workspace is (re)started, use the `onStart` hook + }; + # Enable previews and customize configuration + previews = { + enable = true; + previews = { + web = { + command = ["npm" "run" "dev" "--" "--port" "$PORT" "--hostname" "0.0.0.0"]; + manager = "web"; + }; + }; + }; + }; +} diff --git a/extensions/void/package-lock.json b/extensions/void/package-lock.json index 283fcb8c..73491ed1 100644 --- a/extensions/void/package-lock.json +++ b/extensions/void/package-lock.json @@ -42,7 +42,9 @@ "eslint-plugin-react-hooks": "^4.6.2", "globals": "^15.9.0", "lodash": "^4.17.21", + "groq-sdk": "^0.8.0", + "marked": "^14.1.0", "ollama": "^0.5.9", "openai": "^4.68.4", @@ -4983,6 +4985,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", diff --git a/extensions/void/package.json b/extensions/void/package.json index 2cc8e3a7..4bfa15e6 100644 --- a/extensions/void/package.json +++ b/extensions/void/package.json @@ -144,6 +144,7 @@ "eslint-plugin-react-hooks": "^4.6.2", "globals": "^15.9.0", "groq-sdk": "^0.8.0", + "lodash": "^4.17.21", "marked": "^14.1.0", "ollama": "^0.5.9", diff --git a/extensions/void/src/extension/AutcompleteProvider.ts b/extensions/void/src/extension/AutcompleteProvider.ts index 5ca8fdac..2aad378a 100644 --- a/extensions/void/src/extension/AutcompleteProvider.ts +++ b/extensions/void/src/extension/AutcompleteProvider.ts @@ -63,7 +63,7 @@ const trimPrefix = (prefix: string) => { // originalSuffix = ijkl // the user has typed "ef" so prefix = abcdef // we want to return the rest of the generatedMiddle, which is "gh" -const toInlineCompletion = ({ prefix, autocompletion }: { prefix: string, autocompletion: Autocompletion }): vscode.InlineCompletionItem => { +const toInlineCompletion = ({ prefix, autocompletion, position }: { prefix: string, autocompletion: Autocompletion, position: vscode.Position }): vscode.InlineCompletionItem => { const originalPrefix = autocompletion.prefix const generatedMiddle = autocompletion.result @@ -83,7 +83,10 @@ const toInlineCompletion = ({ prefix, autocompletion }: { prefix: string, autoco const completionStr = generatedMiddle.substring(lastMatchupIndex) console.log('completionStr: ', completionStr) - return new vscode.InlineCompletionItem(completionStr) + return new vscode.InlineCompletionItem( + completionStr, + new vscode.Range(position, position) + ) } @@ -127,6 +130,9 @@ export class AutocompleteProvider implements vscode.InlineCompletionItemProvider token: vscode.CancellationToken, ): Promise { + const disabled = true + if (disabled) { return []; } + const docUriStr = document.uri.toString() const fullText = document.getText(); @@ -156,7 +162,7 @@ export class AutocompleteProvider implements vscode.InlineCompletionItemProvider if (cachedAutocompletion.status === 'finished') { console.log('AAA1') - const inlineCompletion = toInlineCompletion({ autocompletion: cachedAutocompletion, prefix, }) + const inlineCompletion = toInlineCompletion({ autocompletion: cachedAutocompletion, prefix, position }) return [inlineCompletion] } else if (cachedAutocompletion.status === 'pending') { @@ -164,7 +170,7 @@ export class AutocompleteProvider implements vscode.InlineCompletionItemProvider try { await cachedAutocompletion.promise; - const inlineCompletion = toInlineCompletion({ autocompletion: cachedAutocompletion, prefix, }) + const inlineCompletion = toInlineCompletion({ autocompletion: cachedAutocompletion, prefix, position }) return [inlineCompletion] } catch (e) { @@ -260,7 +266,7 @@ export class AutocompleteProvider implements vscode.InlineCompletionItemProvider try { await newAutocompletion.promise; - const inlineCompletion = toInlineCompletion({ autocompletion: newAutocompletion, prefix, }) + const inlineCompletion = toInlineCompletion({ autocompletion: newAutocompletion, prefix, position }) return [inlineCompletion] } catch (e) {