diff --git a/.helix/config.toml b/.helix/config.toml new file mode 100644 index 0000000..2bae06e --- /dev/null +++ b/.helix/config.toml @@ -0,0 +1,5 @@ +theme = "tokyonight_storm" + +[editor.cursor-shape] +insert = "bar" + diff --git a/src/app.ts b/src/app.ts index a5a1f9e..4bbd970 100644 --- a/src/app.ts +++ b/src/app.ts @@ -15,7 +15,8 @@ const main = async () => { triggerCharacters: ["{", "(", ")", "=", ">", " ", ",", ":", ".", "<", "/"] }, textDocumentSync: { - change: 2, + change: 1, + openClose: true } } }) diff --git a/src/completions.ts b/src/completions.ts index bb3bdc0..d66a726 100644 --- a/src/completions.ts +++ b/src/completions.ts @@ -14,7 +14,7 @@ const extractCodeBlock = (filepath: string, text: string, language: string): str } const result = blocks[0]; - + const lines = result.replace(`// FILEPATH: ${filepath.replace('file://', '')}\n`, '').split('\n'); return lines.slice(1, lines.length - 1).join('\n') + "\n"; } @@ -199,6 +199,8 @@ export const chat = async (request: string, contents: string, filepath: string, throw new Error(`chat handler: ${config.handler} does not exist`) } + language = language ?? "unknown" + try { log("running chat handler:", config.handler) return await chatHandlers[config.handler](request, contents, filepath, language) @@ -214,6 +216,8 @@ export const completion = async (contents: any, language: string, suggestions = throw new Error(`completion handler: ${config.handler} does not exist`) } + language = language ?? "unknown" + try { log("running completion handler:", config.handler) return uniqueStringArray(await handlers[config.handler](contents, language, suggestions)) diff --git a/src/lsp.ts b/src/lsp.ts index 2fc926a..b71065a 100644 --- a/src/lsp.ts +++ b/src/lsp.ts @@ -89,6 +89,7 @@ class Service { ctx.contents = request.params.textDocument.text ctx.language = request.params.textDocument.languageId ctx.contentVersion = 0 + log("received didOpen", `language: ${ctx.language}`) }) this.on(Event.Shutdown, () => { @@ -97,12 +98,13 @@ class Service { }) this.on(Event.DidChange, async ({ ctx, request }) => { - request.params.contentChanges.forEach((change) => { - this.positionalUpdate(change.text, change.range) - }) - + // request.params.contentChanges.forEach((change) => { + // this.positionalUpdate(change.text, change.range) + // }) + this.contents = request.params.contentChanges[0].text ctx.currentUri = request.params.textDocument.uri ctx.contentVersion = request.params.textDocument.version + log("received didChange", `language: ${ctx.language}`, `contentVersion: ${ctx.contentVersion}`) }) } @@ -113,7 +115,7 @@ class Service { } positionalUpdate(text: string, range: Range) { - const lines = this.contents.split("\n") + const lines = this.contents?.split("\n") const start = range.start.line const end = range.end.line const startLine = lines[start]