Skip to content

Commit

Permalink
Try building dist
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Mar 25, 2024
1 parent 7726462 commit b6f71f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"pages": "vite build",
"build": "tsc --build"
},
"main": "./dist/plugin.js",
"types": "./dist/plugin.d.ts",
"keywords": [
"codemirror",
"typescript",
Expand Down
26 changes: 14 additions & 12 deletions src/codeium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createPromiseClient } from "@connectrpc/connect";
import { LanguageServerService } from "./api/proto/exa/language_server_pb/language_server_connect.js";
import { createConnectTransport } from "@connectrpc/connect-web";
import { Language } from "./api/proto/exa/codeium_common_pb/codeium_common_pb.js";
import { GetCompletionsResponse } from "./api/proto/exa/language_server_pb/language_server_pb.js";

// This is the same as the monaco editor example
const EDITOR_API_KEY = "d49954eb-cfba-4992-980f-d8fb37f0e942";
Expand All @@ -22,7 +23,7 @@ export async function getCodeiumCompletions({
text: string;
cursorOffset: number;
}) {
const completions = await client.getCompletions(
const completions = (await client.getCompletions(
{
metadata: {
ideName: "web",
Expand Down Expand Up @@ -53,21 +54,22 @@ export async function getCodeiumCompletions({
Authorization: `Basic ${EDITOR_API_KEY}-${sessionId}`,
},
},
);
// TODO: why doesn't this work by default?
)) as GetCompletionsResponse;

const parts = completions.completionItems[0].completionParts
.filter((part) => {
const parts = completions.completionItems[0]!.completionParts.filter(
(part) => {
// Type 3 overwrites existing text. Maybe we need this eventually,
// but not right now and it usually is duplicative.
return part.type !== 3;
})
.map((part) => {
return {
...part,
offset: Number(part.offset),
text: part.type === 2 ? `\n${part.text}` : part.text,
};
});
},
).map((part) => {
return {
...part,
offset: Number(part.offset),
text: part.type === 2 ? `\n${part.text}` : part.text,
};
});

return parts;
}

0 comments on commit b6f71f6

Please sign in to comment.