Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destruct aiderCommand and buffer object, use import as instead #21

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions denops/aider/aiderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,58 @@ 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";

export const aiderCommand = {
async debug(denops: Denops): Promise<void> {
await denops.cmd("b#");
},

async run(denops: Denops): Promise<void> {
const aiderCommand = ensure(
await v.g.get(denops, "aider_command"),
is.String,
);
await denops.cmd(`terminal ${aiderCommand}`);
},
/**
* Aiderをバックグラウンドで実行します。
* 新しいバッファを作成し、Aiderコマンドをターミナルで実行した後、
* 前のバッファに戻ります。
* @param {Denops} denops - Denopsインスタンス
* @returns {Promise<void>}
*/
async silentRun(denops: Denops): Promise<void> {
await denops.cmd("enew");

const aiderCommand = ensure(
await v.g.get(denops, "aider_command"),
is.String,
);
await denops.cmd(`terminal ${aiderCommand}`);

await denops.cmd("b#");

await denops.cmd("echo 'Aider is running in the background.'");
},
/**
* Aiderバッファにメッセージを送信します。
* @param {Denops} denops - Denops instance
* @param {number} jobId - The job id to send the message to
* @param {string} prompt - The prompt to send
* @returns {Promise<void>}
*/
async sendPrompt(
denops: Denops,
jobId: number,
prompt: string,
): Promise<void> {
await v.r.set(denops, "q", prompt);
await fn.feedkeys(denops, "G");
await fn.feedkeys(denops, '"qp');
await denops.call("chansend", jobId, "\n");
},

async exit(denops: Denops, jobId: number, bufnr: number): Promise<void> {
await denops.call("chansend", jobId, "/exit\n");
await denops.cmd(`bdelete! ${bufnr}`);
},
};
export async function debug(denops: Denops): Promise<void> {
await denops.cmd("b#");
}

export async function run(denops: Denops): Promise<void> {
const aiderCommand = ensure(
await v.g.get(denops, "aider_command"),
is.String,
);
await denops.cmd(`terminal ${aiderCommand}`);
}

/**
* Aiderをバックグラウンドで実行します。
* 新しいバッファを作成し、Aiderコマンドをターミナルで実行した後、
* 前のバッファに戻ります。
* @param {Denops} denops - Denopsインスタンス
* @returns {Promise<void>}
*/
export async function silentRun(denops: Denops): Promise<void> {
await denops.cmd("enew");

const aiderCommand = ensure(
await v.g.get(denops, "aider_command"),
is.String,
);
await denops.cmd(`terminal ${aiderCommand}`);

await denops.cmd("b#");

await denops.cmd("echo 'Aider is running in the background.'");
}

/**
* Aiderバッファにメッセージを送信します。
* @param {Denops} denops - Denops instance
* @param {number} jobId - The job id to send the message to
* @param {string} prompt - The prompt to send
* @returns {Promise<void>}
*/
export async function sendPrompt(
denops: Denops,
jobId: number,
prompt: string,
): Promise<void> {
await v.r.set(denops, "q", prompt);
await fn.feedkeys(denops, "G");
await fn.feedkeys(denops, '"qp');
await denops.call("chansend", jobId, "\n");
}

export async function exit(denops: Denops, jobId: number, bufnr: number): Promise<void> {
await denops.call("chansend", jobId, "/exit\n");
await denops.cmd(`bdelete! ${bufnr}`);
}
Loading