Skip to content

Commit

Permalink
feat: Aiderに現在のファイルを追加します。
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowasabi committed Aug 4, 2024
1 parent acdaf15 commit 236d4fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
22 changes: 22 additions & 0 deletions denops/aider/aiderCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Denops } from "https://deno.land/x/denops_std@v5.0.1/mod.ts";
import * as v from "https://deno.land/x/denops_std@v6.4.0/variable/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.17.0/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";
import { getCurrentFilePath, getTerminalBufferNr } from "./utils.ts";
import { buffer } from "./buffer.ts";

export const aiderCommand = {
async debug(denops: Denops): Promise<void> {
Expand All @@ -14,4 +17,23 @@ export const aiderCommand = {
);
await denops.cmd(`terminal ${aiderCommand}`);
},
/**
* 現在のファイルをAiderに追加します。
* @param {Denops} denops - Denopsインスタンス
* @returns {Promise<void>}
*/
async addCurrentFile(denops: Denops): Promise<void> {
const bufnr = await fn.bufnr(denops, "%");
if (await getTerminalBufferNr(denops) === undefined) {
await this.run(denops);
}
const bufType = await fn.getbufvar(denops, bufnr, "&buftype");
if (bufType === "terminal") {
return;
}
const currentFile = await getCurrentFilePath(denops);
const prompt = `/add ${currentFile}`;
await v.r.set(denops, "q", prompt);
await buffer.sendPromptWithInput(denops);
},
};
13 changes: 1 addition & 12 deletions denops/aider/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ export async function main(denops: Denops): Promise<void> {
await buffer.sendPromptWithInput(denops);
},
async addCurrentFile(): Promise<void> {
const bufnr = await fn.bufnr(denops, "%");
if (await getTerminalBufferNr(denops) === undefined) {
await this.silentRunAider();
}
const bufType = await fn.getbufvar(denops, bufnr, "&buftype");
if (bufType === "terminal") {
return;
}
const currentFile = await getCurrentFilePath(denops);
const prompt = `/add ${currentFile}`;
await v.r.set(denops, "q", prompt);
await this.sendPromptWithInput();
await aiderCommand.addCurrentFile(denops);
},
async addFile(path: unknown): Promise<void> {
if (path === "") {
Expand Down

0 comments on commit 236d4fc

Please sign in to comment.